From 63295f1f7fa052fabcb4d69d49203cf33a7deef0 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 1 Jun 2020 15:07:58 -0300 Subject: 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. --- lparser.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lparser.h') 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 { } ind; struct { /* for local variables */ lu_byte sidx; /* index in the stack */ - unsigned short vidx; /* index in 'actvar.arr' */ + unsigned short vidx; /* compiler index (in 'actvar.arr') */ } var; } u; int t; /* patch list of 'exit when true' */ @@ -125,7 +125,7 @@ typedef struct Labellist { /* dynamic structures used by the parser */ typedef struct Dyndata { - struct { /* list of active local variables */ + struct { /* list of all active local variables */ Vardesc *arr; int n; int size; -- cgit v1.2.3-55-g6feb