fix code generation for "return <void function call>"

This commit is contained in:
Irmen de Jong committed 2026-09-17 22:39:53 +02:00
1 parent 7f3b2e8aa6
commit ba76fbfe85
4 files changed
+81 -1

No files matched your search

@@ -1895,7 +1895,14 @@ class IRCodeGen(
}
val value = ret.children.singleOrNull()
if(value==null) {
if(ret.numReturnValues()==0) {
// a void subroutine may return the result of a void function call (e.g. "return voidfunc(args)"):
// translate the call for its side effects, then return void
val callValue = value as? PtExpression
if(callValue!=null)
result += expressionEval.translateExpression(callValue).chunks
addInstr(result, IRInstructions.returnVoid(), null)
} else if(value==null) {
addInstr(result, IRInstructions.returnVoid(), null)
} else {
value as PtExpression