summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2016-03-07 16:25:39 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2016-03-07 16:25:39 -0300
commite7b2e01d43d9c3ab6d223daa18eebb94a322e082 (patch)
tree0f6ba55c0b90037e47ef6ee061c1ec51e526d99a
parent03ca6385dc426fefabe9204037fc76ebf0627a11 (diff)
downloadlua-e7b2e01d43d9c3ab6d223daa18eebb94a322e082.tar.gz
lua-e7b2e01d43d9c3ab6d223daa18eebb94a322e082.tar.bz2
lua-e7b2e01d43d9c3ab6d223daa18eebb94a322e082.zip
bug: label between local definitions can mix-up their initializations
-rw-r--r--bugs33
-rw-r--r--lparser.c4
2 files changed, 35 insertions, 2 deletions
diff --git a/bugs b/bugs
index 36eb87e5..38d295ae 100644
--- a/bugs
+++ b/bugs
@@ -3542,6 +3542,39 @@ patch = [[
3542} 3542}
3543 3543
3544 3544
3545Bug{
3546what = [[label between local definitions can mix-up their initializations]],
3547report = [[Karel Tuma, 2016/03/01]],
3548since = [[5.2]],
3549fix = nil,
3550example = [[
3551do
3552 local k = 0
3553 local x
3554 ::foo::
3555 local y -- should be reset to nil after goto, but it is not
3556 assert(not y)
3557 y = true
3558 k = k + 1
3559 if k < 2 then goto foo end
3560end
3561]],
3562patch = [[
3563--- lparser.c 2015/11/02 16:09:30 2.149
3564+++ lparser.c 2016/03/03 12:03:37
3565@@ -1226,7 +1226,7 @@
3566 checkrepeated(fs, ll, label); /* check for repeated labels */
3567 checknext(ls, TK_DBCOLON); /* skip double colon */
3568 /* create new entry for this label */
3569- l = newlabelentry(ls, ll, label, line, fs->pc);
3570+ l = newlabelentry(ls, ll, label, line, luaK_getlabel(fs));
3571 skipnoopstat(ls); /* skip other no-op statements */
3572 if (block_follow(ls, 0)) { /* label is last no-op statement in the block? */
3573 /* assume that locals are already out of scope */
3574]]
3575}
3576
3577
3545--[=[ 3578--[=[
3546Bug{ 3579Bug{
3547what = [[ ]], 3580what = [[ ]],
diff --git a/lparser.c b/lparser.c
index 757d6546..0b5d75a8 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 2.150 2015/12/09 15:21:28 roberto Exp roberto $ 2** $Id: lparser.c,v 2.151 2016/01/05 16:22:37 roberto Exp roberto $
3** Lua Parser 3** Lua Parser
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -1230,7 +1230,7 @@ static void labelstat (LexState *ls, TString *label, int line) {
1230 checkrepeated(fs, ll, label); /* check for repeated labels */ 1230 checkrepeated(fs, ll, label); /* check for repeated labels */
1231 checknext(ls, TK_DBCOLON); /* skip double colon */ 1231 checknext(ls, TK_DBCOLON); /* skip double colon */
1232 /* create new entry for this label */ 1232 /* create new entry for this label */
1233 l = newlabelentry(ls, ll, label, line, fs->pc); 1233 l = newlabelentry(ls, ll, label, line, luaK_getlabel(fs));
1234 skipnoopstat(ls); /* skip other no-op statements */ 1234 skipnoopstat(ls); /* skip other no-op statements */
1235 if (block_follow(ls, 0)) { /* label is last no-op statement in the block? */ 1235 if (block_follow(ls, 0)) { /* label is last no-op statement in the block? */
1236 /* assume that locals are already out of scope */ 1236 /* assume that locals are already out of scope */