Fix environment propogation from function to function.
This commit is contained in:
@@ -843,7 +843,7 @@ public class LuaState extends Lua {
|
|||||||
case LuaState.OP_CLOSURE: {
|
case LuaState.OP_CLOSURE: {
|
||||||
b = LuaState.GETARG_Bx(i);
|
b = LuaState.GETARG_Bx(i);
|
||||||
proto = cl.p.p[b];
|
proto = cl.p.p[b];
|
||||||
newClosure = new LClosure(proto, _G);
|
newClosure = new LClosure(proto, cl.env);
|
||||||
for (int j = 0; j < newClosure.upVals.length; j++, ci.pc++) {
|
for (int j = 0; j < newClosure.upVals.length; j++, ci.pc++) {
|
||||||
i = code[ci.pc];
|
i = code[ci.pc];
|
||||||
o = LuaState.GET_OPCODE(i);
|
o = LuaState.GET_OPCODE(i);
|
||||||
|
|||||||
@@ -1,8 +1,16 @@
|
|||||||
-- helper file for require() tests
|
-- helper file for require() tests
|
||||||
|
require 'ids'
|
||||||
|
print( 'in subsample (before module statement)' )
|
||||||
|
print( 'env', id(getfenv()), '_G', id(_G), '_NAME', _NAME, '_M', id(_M), '_PACKAGE', _PACKAGE )
|
||||||
module( 'req.subsample', package.seeall )
|
module( 'req.subsample', package.seeall )
|
||||||
|
|
||||||
|
print( 'in subsample (after module statement)' )
|
||||||
|
print( 'env', id(getfenv()), '_G', id(_G), '_NAME', _NAME, '_M', id(_M), '_PACKAGE', _PACKAGE )
|
||||||
function h()
|
function h()
|
||||||
print 'in subsample.h'
|
print 'in subsample.h'
|
||||||
|
print( 'env', id(getfenv()), '_G', id(_G), '_NAME', _NAME, '_M', id(_M), '_PACKAGE', _PACKAGE )
|
||||||
end
|
end
|
||||||
print 'loading subsample.lua'
|
print 'loading subsample.lua'
|
||||||
|
h()
|
||||||
return 'return value from subsample', 'second return value from subsample'
|
return 'return value from subsample', 'second return value from subsample'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user