Fix for-loop real widening coercions

This commit is contained in:
sergeych committed 2026-02-16 16:53:53 +03:00
1 parent fd2da1efd3
commit a8f6aa31f1
3 files changed
+57

No files matched your search

@@ -1258,6 +1258,28 @@ class ScriptTest {
)
}
@Test
fun testForLoopRealWidenDisasm() = runTest {
val scope = Script.newScope()
scope.eval(
"""
fun widenFor() {
var acc = 0
for(i in 0..3) {
if (i == 1) acc = 0.5
}
}
""".trimIndent()
)
val disasm = scope.disassembleSymbol("widenFor")
println("[DEBUG_LOG] widenFor disasm:\n$disasm")
val incIndex = disasm.indexOf("INC_INT")
assertTrue(incIndex >= 0, "expected INC_INT in for-loop disasm")
val convIndex = disasm.indexOf("INT_TO_REAL")
assertTrue(convIndex >= 0, "expected INT_TO_REAL in for-loop disasm")
assertTrue(convIndex > incIndex, "INT_TO_REAL should appear after INC_INT")
}
@Test
fun testIntClosedRangeInclusive() = runTest {
eval(