lua-users home
lua-l archive

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


Consider the following code:

print(loadin({}, string.dump(function()return end))) --> table

The loadin function in 5.2-work4 seems to assume that there will be an
upvalue to set, as it doesn't check the return value of
lua_setupvalue, and hence leaves the new environment on the top of the
stack if the loaded chunk has no upvalues, thus causing the return
value to be the environment rather than the loaded chunk. The
documentation for loadin does explicitly mention that it sets the
first upvalue, so the correct behaviour is not really specified, but I
suspect that it should be to not set any upvalues and return the
loaded chunk.