From 3db5f60547d6f31892071f5c00032dfb79a8f729 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 15 Jun 2009 10:52:08 -0300 Subject: [PATCH] BUG: "(((1 or false) and true) or false)" gives wrong result --- lcode.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lcode.c b/lcode.c index 2b932b94..87bf2f92 100644 --- 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;