-
Notifications
You must be signed in to change notification settings - Fork 480
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Given the following program with regular Lua 5.1:
int main()
{
lua_State* L = luaL_newstate();
const char* source = "return \"test\"";
size_t sourceSize = strlen(source);
luaL_loadbuffer(L, source, sourceSize, "test");
lua_call(L, 0, 1);
printf("type = %d\n", lua_type(L, -1));
int r = luaL_ref(L, LUA_REGISTRYINDEX);
lua_rawgeti(L, LUA_REGISTRYINDEX, r);
printf("type = %d\n", lua_type(L, -1));
lua_close(L);
return 0;
}The output is, as one would expect:
type = 4
type = 4
When the following similar program is run on Luau:
int main()
{
lua_State* L = luaL_newstate();
const char* source = "return \"test\"";
size_t sourceSize = strlen(source);
size_t bytecodeSize;
char* bytecode = luau_compile(source, sourceSize, nullptr, &bytecodeSize);
luau_load(L, "test", bytecode, bytecodeSize, 0);
lua_call(L, 0, 1);
printf("type = %d\n", lua_type(L, -1));
int r = lua_ref(L, LUA_REGISTRYINDEX);
lua_rawgeti(L, LUA_REGISTRYINDEX, r);
printf("type = %d\n", lua_type(L, -1));
lua_close(L);
return 0;
}The types are suddenly different:
type = 5
type = 6
With 5 being LUA_TSTRING and 6 being LUA_TTABLE.
Perhaps I'm missing something in the difference between lua_ref and luaL_ref, but this seems wrong to me on first sight.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working