From 60bc151ed70bce0d534edcbbba4380dee4306708 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 9 Mar 2007 15:51:32 -0300 Subject: [PATCH] patch for last bug --- bugs | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/bugs b/bugs index 57eef557..34c72255 100644 --- a/bugs +++ b/bugs @@ -1252,7 +1252,45 @@ print(2 * v251.k1, v251.k1 * 2); -- 2 2, OK v253=1; print(2 * v251.k1, v251.k1 * 2); -- 1 2, ??? ]], -patch = [[no patch yet]], +patch = [[ +*lcode.c: +@@ -657,10 +657,16 @@ + if (constfolding(op, e1, e2)) + return; + else { +- int o1 = luaK_exp2RK(fs, e1); + int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0; +- freeexp(fs, e2); +- freeexp(fs, e1); ++ int o1 = luaK_exp2RK(fs, e1); ++ if (o1 > o2) { ++ freeexp(fs, e1); ++ freeexp(fs, e2); ++ } ++ else { ++ freeexp(fs, e2); ++ freeexp(fs, e1); ++ } + e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2); + e1->k = VRELOCABLE; + } +@@ -718,10 +724,15 @@ + luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */ + break; + } +- default: { ++ case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: ++ case OPR_MOD: case OPR_POW: { + if (!isnumeral(v)) luaK_exp2RK(fs, v); + break; + } ++ default: { ++ luaK_exp2RK(fs, v); ++ break; ++ } + } + } +]], } Bug{