diff --git a/lcode.c b/lcode.c index 87616140..3f78370c 100644 --- a/lcode.c +++ b/lcode.c @@ -35,6 +35,7 @@ #define MAXREGS 255 +/* (note that expressions VJMP also have jumps.) */ #define hasjumps(e) ((e)->t != (e)->f) @@ -985,7 +986,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 ea038e82..37271472 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 = {}