lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Fri, Apr 24, 2009 at 9:02 PM, David Manura wrote:
> Consider this variant: ...

Nevermind, it was basically already stated, but here's another:

> local x =true; return (1 or 2) and x or 4
true  -- correct

There is something wrong with the bytecodes:

$ echo 'return (1 or 2) and true or 4' | luac -p -l -

main <stdin:0,0> (10 instructions, 40 bytes at 0x680e00)
0+ params, 2 slots, 0 upvalues, 0 locals, 2 constants, 0 functions
        1       [1]     LOADK           0 -1    ; 1
        2       [1]     TEST            0 0 1
        3       [1]     JMP             5       ; to 9
        4       [1]     JMP             3       ; to 8
        5       [1]     LOADK           0 -2    ; 4
        6       [1]     JMP             2       ; to 9
        7       [1]     LOADBOOL        0 0 1
        8       [1]     LOADBOOL        0 1 0
        9       [1]     RETURN          0 2
        10      [1]     RETURN          0 1