lua-users home
lua-l archive

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


> I have encountered an unusual compiler bug that only happens under specific
> conditions that results in the improper generation of certain conditions
> involving integers (?)
> 
> [...]

Many thanks for the report and the initial analysis.


> The following code will output 0 even though it still should be evaluating
> 1 ~ 2. When the bytecode for this is viewed, it looks that the TESTSET
> generated jumps over the LOADI for 1, which seems to be misplaced? When any
> other value type is used, a TEST is generated instead of TESTSET and the
> LOADI is placed normally.

The problem is the interleaving of the code generation of both
expressions. Usually, if e1 is a constant that fits in K, it generates
no code and all goes well. If e1 is not a constant, its code is
generated before e2 and all goes well. However, if e1 is a constant
that doesn't fit in K, its LOADI is generated after a part of e2 has
been generated (up to the TEST). When we finish e2, it sees that
LOADI as part of itself, which confuses the generator.

Not sure yet what is a simple way to fix that...

-- Roberto