diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-06-01 15:07:58 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-06-01 15:07:58 -0300 |
commit | 63295f1f7fa052fabcb4d69d49203cf33a7deef0 (patch) | |
tree | 05ba23f84fc76bd9a6b44883e7527ca1afcd274e /lparser.h | |
parent | 50523b107d5bcc8069b1aec4b5b11b3fcc87da8d (diff) | |
download | lua-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.h | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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 */ |
127 | typedef struct Dyndata { | 127 | typedef 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; |