[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Bug in Lua code generator
- From: roberto@... (Roberto Ierusalimschy)
- Date: Sat, 28 Apr 2007 22:01:38 -0300
> (This bug was discovered by David Manura.)
>
> The unary operators, OP_UNM, OP_LEN and OP_NOT do not allow constants for
> the B operand. It's not clear to me why not, but in any case, the test at
> line 702 of lcode.c is incorrect:
>
> [...]
Many thanks fro the report. BTW, OP_UNM does not accept constants
because that would make the instruction slower in the general case
only to optimize the most improbable case of negating a literal string
(e.g., -"123"), as negating numeral constants are done at compile time.
> The solution would be either to make OP_UNM accept RK(B) instead of just
> R(B), or to change the test in line 702 of lcode.c to include VNIL, VFALSE
> and VTRUE
Maybe it would be better to reverse the test?
if (!isnumeral(e))
...
-- Roberto