lua

A copy of the Lua development repository
Log | Files | Refs | README

commit 3db5f60547d6f31892071f5c00032dfb79a8f729
parent 2258ec6bc94bc127024a49e29a0b40f58a5ae0a3
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Mon, 15 Jun 2009 10:51:44 -0300

BUG: "(((1 or false) and true) or false)" gives wrong result

Diffstat:
Mlcode.c | 24+++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/lcode.c b/lcode.c @@ -1,5 +1,5 @@ /* -** $Id: lcode.c,v 2.36 2008/04/07 18:41:47 roberto Exp roberto $ +** $Id: lcode.c,v 2.37 2009/06/10 16:52:03 roberto Exp roberto $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -543,15 +543,18 @@ void luaK_goiftrue (FuncState *fs, expdesc *e) { pc = NO_JUMP; /* always true; do nothing */ break; } - case VFALSE: { - pc = luaK_jump(fs); /* always jump */ - break; - } case VJMP: { invertjump(fs, e); pc = e->u.s.info; break; } + case VFALSE: { + if (!hasjumps(e)) { + pc = luaK_jump(fs); /* always jump */ + break; + } + /* else go through */ + } default: { pc = jumponcond(fs, e, 0); break; @@ -571,14 +574,17 @@ static void luaK_goiffalse (FuncState *fs, expdesc *e) { pc = NO_JUMP; /* always false; do nothing */ break; } - case VTRUE: { - pc = luaK_jump(fs); /* always jump */ - break; - } case VJMP: { pc = e->u.s.info; break; } + case VTRUE: { + if (!hasjumps(e)) { + pc = luaK_jump(fs); /* always jump */ + break; + } + /* else go through */ + } default: { pc = jumponcond(fs, e, 1); break;