lua-users home
lua-l archive

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


> >> 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, [...]
> >
> > I think it should raise an error if the chunk does not have a first
> > upvalue or if this upvalue is not called _ENV.
> 
> Well if you're simply trying to sandbox foreign code, you can't really
> anticipate whether it will actually use globals or not... (I don't
> think an error would be helpful, just report success?)

A main chunk always have an _ENV upvalue, even if it does not use
any global. The only case where a chunk may not have _ENV as its
first upvalue is when loading a binary dump of a non-main function.

-- Roberto