aboutsummaryrefslogtreecommitdiff
path: root/lparser.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-06-01 15:07:58 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-06-01 15:07:58 -0300
commit63295f1f7fa052fabcb4d69d49203cf33a7deef0 (patch)
tree05ba23f84fc76bd9a6b44883e7527ca1afcd274e /lparser.h
parent50523b107d5bcc8069b1aec4b5b11b3fcc87da8d (diff)
downloadlua-63295f1f7fa052fabcb4d69d49203cf33a7deef0.tar.gz
lua-63295f1f7fa052fabcb4d69d49203cf33a7deef0.tar.bz2
lua-63295f1f7fa052fabcb4d69d49203cf33a7deef0.zip
Fixed two bugs in to-be-closed variables x constants
The parser were mixing compiler indices of variables with stack indices, so that when a to-be-closed variable was used inside the scope of compile-time constants (which may be optimized away), it might be closed in the wrong place. (See new tests for examples.) Besides fixing the bugs, this commit also changed comments and variable names to avoid that kind of confusion and added tests.
Diffstat (limited to 'lparser.h')
-rw-r--r--lparser.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/lparser.h b/lparser.h
index f544492e..618cb010 100644
--- a/lparser.h
+++ b/lparser.h
@@ -77,7 +77,7 @@ typedef struct expdesc {
77 } ind; 77 } ind;
78 struct { /* for local variables */ 78 struct { /* for local variables */
79 lu_byte sidx; /* index in the stack */ 79 lu_byte sidx; /* index in the stack */
80 unsigned short vidx; /* index in 'actvar.arr' */ 80 unsigned short vidx; /* compiler index (in 'actvar.arr') */
81 } var; 81 } var;
82 } u; 82 } u;
83 int t; /* patch list of 'exit when true' */ 83 int t; /* patch list of 'exit when true' */
@@ -125,7 +125,7 @@ typedef struct Labellist {
125 125
126/* dynamic structures used by the parser */ 126/* dynamic structures used by the parser */
127typedef struct Dyndata { 127typedef struct Dyndata {
128 struct { /* list of active local variables */ 128 struct { /* list of all active local variables */
129 Vardesc *arr; 129 Vardesc *arr;
130 int n; 130 int n;
131 int size; 131 int size;