From 53bd4bf71fb353e5e9da29f4448ec51b2b8374c2 Mon Sep 17 00:00:00 2001 From: Enyby Date: Sat, 2 Nov 2019 17:02:21 +0200 Subject: [PATCH] Fix compiler Bug{ what = [[label between local definitions can mix-up their initializations]], report = [[Karel Tuma, 2016/03/01]], since = [[5.2]], fix = nil, example = [[ do local k = 0 local x ::foo:: local y -- should be reset to nil after goto, but it is not assert(not y) y = true k = k + 1 if k < 2 then goto foo end end ]], patch = [[ --- lparser.c 2015/11/02 16:09:30 2.149 +++ lparser.c 2016/03/03 12:03:37 @@ -1226,7 +1226,7 @@ checkrepeated(fs, ll, label); /* check for repeated labels */ checknext(ls, TK_DBCOLON); /* skip double colon */ /* create new entry for this label */ - l = newlabelentry(ls, ll, label, line, fs->pc); + l = newlabelentry(ls, ll, label, line, luaK_getlabel(fs)); skipnoopstat(ls); /* skip other no-op statements */ if (block_follow(ls, 0)) { /* label is last no-op statement in the block? */ /* assume that locals are already out of scope */ ]] } --- src/core/org/luaj/vm2/compiler/LexState.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/org/luaj/vm2/compiler/LexState.java b/src/core/org/luaj/vm2/compiler/LexState.java index 6e6a6708..0192de05 100644 --- a/src/core/org/luaj/vm2/compiler/LexState.java +++ b/src/core/org/luaj/vm2/compiler/LexState.java @@ -1748,7 +1748,7 @@ public class LexState extends Constants { fs.checkrepeated(dyd.label, dyd.n_label, label); /* check for repeated labels */ checknext(TK_DBCOLON); /* skip double colon */ /* create new entry for this label */ - l = newlabelentry(dyd.label=grow(dyd.label, dyd.n_label+1), dyd.n_label++, label, line, fs.pc); + l = newlabelentry(dyd.label=grow(dyd.label, dyd.n_label+1), dyd.n_label++, label, line, fs.getlabel()); skipnoopstat(); /* skip other no-op statements */ if (block_follow(false)) { /* label is last no-op statement in the block? */ /* assume that locals are already out of scope */