diff --git a/src/lcode.cpp b/src/lcode.cpp index 7ec569c2c..087f74825 100644 --- a/src/lcode.cpp +++ b/src/lcode.cpp @@ -32,6 +32,7 @@ #define MAXREGS 255 +/* (note that expressions VJMP also have jumps.) */ #define hasjumps(e) ((e)->t != (e)->f) @@ -1001,7 +1002,7 @@ void luaK_exp2anyregup (FuncState *fs, expdesc *e) { ** or it is a constant. */ void luaK_exp2val (FuncState *fs, expdesc *e) { - if (hasjumps(e)) + if (e->k == VJMP || hasjumps(e)) luaK_exp2anyreg(fs, e); else luaK_dischargevars(fs, e); diff --git a/testes/closure.lua b/testes/closure.lua index ea038e824..37271472a 100644 --- a/testes/closure.lua +++ b/testes/closure.lua @@ -3,6 +3,14 @@ print "testing closures" +do -- bug in 5.4.7 + _ENV[true] = 10 + local function aux () return _ENV[1 < 2] end + assert(aux() == 10) + _ENV[true] = nil +end + + local A,B = 0,{g=10} local function f(x) local a = {}