lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> I'm using the latest 5.4 sources from github. lua_rawgetp appears to pop an 
> extra value from the stack, and fails an API check if that value isn't a 
> table. E.g. lua_rawgetp(L, -1, foo) effectively replaces the table with the 
> retrieved value in the stack. I haven't tested it too thoroughly, but I 
> believe that in the following situation
> 
> 	push_some_nonempty_table(L);
> 	lua_newtable(L);
> 	lua_rawgetp(L, -2, foo);
> 
> it would pop the empty table but correctly retrieve the value from the one 
> before it... which is just plain weird. lua_rawgeti is not affected by this 
> and works as you'd expect: nothing is popped, 1 value is pushed.

Are you sure about it? I ran exactly the code you wrote and got a
correct behavior. No API check failed, both tables remain on the
stack, and the value at index 'foo' on the first table was correctly
retrieved. If I remove the lua_newtable and use -1 as index, also
everything seems to work correctly.

-- Roberto