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

This commit is contained in:
Roberto Ierusalimschy 2009-06-15 10:52:08 -03:00
parent 2258ec6bc9
commit 3db5f60547
1 changed files with 15 additions and 9 deletions

24
lcode.c
View File

@ -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 ** Code generator for Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -543,15 +543,18 @@ void luaK_goiftrue (FuncState *fs, expdesc *e) {
pc = NO_JUMP; /* always true; do nothing */ pc = NO_JUMP; /* always true; do nothing */
break; break;
} }
case VFALSE: {
pc = luaK_jump(fs); /* always jump */
break;
}
case VJMP: { case VJMP: {
invertjump(fs, e); invertjump(fs, e);
pc = e->u.s.info; pc = e->u.s.info;
break; break;
} }
case VFALSE: {
if (!hasjumps(e)) {
pc = luaK_jump(fs); /* always jump */
break;
}
/* else go through */
}
default: { default: {
pc = jumponcond(fs, e, 0); pc = jumponcond(fs, e, 0);
break; break;
@ -571,14 +574,17 @@ static void luaK_goiffalse (FuncState *fs, expdesc *e) {
pc = NO_JUMP; /* always false; do nothing */ pc = NO_JUMP; /* always false; do nothing */
break; break;
} }
case VTRUE: {
pc = luaK_jump(fs); /* always jump */
break;
}
case VJMP: { case VJMP: {
pc = e->u.s.info; pc = e->u.s.info;
break; break;
} }
case VTRUE: {
if (!hasjumps(e)) {
pc = luaK_jump(fs); /* always jump */
break;
}
/* else go through */
}
default: { default: {
pc = jumponcond(fs, e, 1); pc = jumponcond(fs, e, 1);
break; break;