[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Bug in 5.2-work4's loadin when loading chunks with no upvalues?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Mon, 23 Aug 2010 14:54:48 -0300
> 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.
I think it should raise an error if the chunk does not have a first
upvalue or if this upvalue is not called _ENV.
-- Roberto