Skip to content

Commit 4e47e34

Browse files
authored
fix(virtualmachine): correct rk decoding for false values (#6)
Replace the RK (register or constant) helper's `or` fallback with an explicit branch so RK operands aren't mis-resolved when a register contains `false`, fixing cases like `false == nil` evaluating incorrectly.
1 parent ca95cdb commit 4e47e34

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

the-tiny-lua-compiler.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3774,7 +3774,8 @@ function VirtualMachine:executeClosure(...)
37743774
-- in our implementation, so in order to get the correct constant,
37753775
-- we negate the index when accessing the constants table.
37763776
local function rk(index)
3777-
return stack[index] or constants[-index]
3777+
if index < 0 then return constants[-index] end
3778+
return stack[index]
37783779
end
37793780

37803781
-- Initialize parameters.

0 commit comments

Comments
 (0)