prog8
prog8 copied to clipboard
compiler crash when using call builtin
The following PR exhibits the issue. When building the target repo with this PR:
* internal error *
Exception in thread "main" kotlin.UninitializedPropertyAccessException: lateinit property parent has not been initialized
at prog8.code.ast.PtNode.getParent(AstBase.kt:15)
at prog8.code.ast.PtNode.definingBlock(AstBase.kt:129)
at prog8.codegen.cpu6502.AsmGen6502.prefixSymbols$prefixSymbols(AsmGen.kt:59)
at prog8.codegen.cpu6502.AsmGen6502.prefixSymbols$prefixSymbols(AsmGen.kt:93)
at prog8.codegen.cpu6502.AsmGen6502.prefixSymbols$prefixSymbols(AsmGen.kt:93)
at prog8.codegen.cpu6502.AsmGen6502.prefixSymbols$prefixSymbols(AsmGen.kt:93)
at prog8.codegen.cpu6502.AsmGen6502.prefixSymbols$prefixSymbols(AsmGen.kt:93)
at prog8.codegen.cpu6502.AsmGen6502.prefixSymbols(AsmGen.kt:98)
at prog8.codegen.cpu6502.AsmGen6502.generate(AsmGen.kt:27)
at prog8.compiler.CompilerKt.createAssemblyAndAssemble(Compiler.kt:496)
at prog8.compiler.CompilerKt.compileProgram(Compiler.kt:147)
at prog8.CompilerMainKt.compileMain(CompilerMain.kt:262)
at prog8.CompilerMainKt.main(CompilerMain.kt:28)
make: *** [Makefile:30: hworld.prg] Error 1
I think I know, what could cause it?
void = call(workFunc)
technically, the correct syntax for ignoring a return value from a single return value function is this:
void call(workFunc)
void =
syntax wasn't a thing until multi-return syntax was added recently, and I guess the handling of void =
for regular functions wasn't added, so stuff happen.
But that's just my thesis.
Yup, that fixes it. That's a fine workaround for me! (I'm used to that syntax.)
I'll let you ( @irmen ) decide whether to keep this open to handle that or just close it.
yeah, let desertfish see it, so he can add a proper error message
With -target virtual, it also crashes, but with a different error
Exception in thread "main" java.lang.IllegalArgumentException: node prog8.code.ast.PtFunctionCall@ccd1bc3 name is not scoped: call at prog8.codegen.intermediate.IRCodeGen.verifyNameScoping$verifyPtNode(IRCodeGen.kt:65) at prog8.codegen.intermediate.IRCodeGen.verifyNameScoping$verifyPtNode(IRCodeGen.kt:79) at prog8.codegen.intermediate.IRCodeGen.verifyNameScoping$verifyPtNode(IRCodeGen.kt:79) at prog8.codegen.intermediate.IRCodeGen.verifyNameScoping$verifyPtNode(IRCodeGen.kt:79) at prog8.codegen.intermediate.IRCodeGen.verifyNameScoping(IRCodeGen.kt:90) at prog8.codegen.intermediate.IRCodeGen.generate(IRCodeGen.kt:26)
Minimal reproduction:
main {
sub start() {
void = call($2000)
}
}
related compiler crash:
main {
sub start() {
void = 123
}
}