dibyendumajumdar / ravi

Ravi is a dialect of Lua, featuring limited optional static typing, JIT and AOT compilers
http://ravilang.github.io/
Other
1.16k stars 60 forks source link

Discrepancy of OP_RAVI_TOSTRING between VM and JIT #225

Open XmiliaH opened 3 years ago

XmiliaH commented 3 years ago

As noted in https://github.com/dibyendumajumdar/ravi/issues/223#issuecomment-845122991 there is a discrepancy between the VM and JIT for the OP_RAVI_TOSTRING. The VM allows nil, however, the JIT doesn't. Following code produces an error after the function is compiled:

function test(s: string)
    return s
end

print(test(nil))

ravi.compile(test)

print(test(nil))
XmiliaH commented 3 years ago

The same behavior can be seen for closure.

snoopcatt commented 3 years ago

Yay, really.

It turns out that we don't have to break backwards compatibility with proposed change. Because it's already broken (between JIT and VM) :smoking:

dibyendumajumdar commented 3 years ago

Sorry my bad. I think my original LLVM backend matched the interpreter semantics.

dibyendumajumdar commented 3 years ago

For now I pushed some changes to improve consistency between JIT & VM.

dibyendumajumdar commented 3 years ago

Hi @XmiliaH if you are able to check that the behavior is consistent now please let me know.