diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-08-17 12:37:04 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-08-17 12:47:28 -0300 |
commit | 8b752ddf14c1987411906d07a8c68f72f168b9b7 (patch) | |
tree | 6fe4b16cae918d5531697ea2a10e60dea982f5bc /lcode.c | |
parent | 1bf4b80f1ace8384eb9dd6f7f8b67256b3944a7a (diff) | |
download | lua-8b752ddf14c1987411906d07a8c68f72f168b9b7.tar.gz lua-8b752ddf14c1987411906d07a8c68f72f168b9b7.tar.bz2 lua-8b752ddf14c1987411906d07a8c68f72f168b9b7.zip |
Bug: wrong code gen. for indices with comparisons
In function 'luaK_exp2val', used to generate code for indices: Macro
'hasjumps' does not consider the case when the whole expression is a
"jump" (a test). In all other of its uses, the surrounding code ensures
that the expression cannot be VJMP.
Diffstat (limited to 'lcode.c')
-rw-r--r-- | lcode.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -31,6 +31,7 @@ | |||
31 | #include "lvm.h" | 31 | #include "lvm.h" |
32 | 32 | ||
33 | 33 | ||
34 | /* (note that expressions VJMP also have jumps.) */ | ||
34 | #define hasjumps(e) ((e)->t != (e)->f) | 35 | #define hasjumps(e) ((e)->t != (e)->f) |
35 | 36 | ||
36 | 37 | ||
@@ -991,7 +992,7 @@ void luaK_exp2anyregup (FuncState *fs, expdesc *e) { | |||
991 | ** or it is a constant. | 992 | ** or it is a constant. |
992 | */ | 993 | */ |
993 | void luaK_exp2val (FuncState *fs, expdesc *e) { | 994 | void luaK_exp2val (FuncState *fs, expdesc *e) { |
994 | if (hasjumps(e)) | 995 | if (e->k == VJMP || hasjumps(e)) |
995 | luaK_exp2anyreg(fs, e); | 996 | luaK_exp2anyreg(fs, e); |
996 | else | 997 | else |
997 | luaK_dischargevars(fs, e); | 998 | luaK_dischargevars(fs, e); |