diff --git a/compiler/src/main/kotlin/gay/pizza/pork/compiler/IrStubOpEmitter.kt b/compiler/src/main/kotlin/gay/pizza/pork/compiler/IrStubOpEmitter.kt index 5601918..2664ba7 100644 --- a/compiler/src/main/kotlin/gay/pizza/pork/compiler/IrStubOpEmitter.kt +++ b/compiler/src/main/kotlin/gay/pizza/pork/compiler/IrStubOpEmitter.kt @@ -18,6 +18,7 @@ class IrStubOpEmitter(val irDefinition: IrDefinition, val code: CodeBuilder) : I fun final() { if (code.lastOp()?.op?.code != Opcode.Return) { + code.emit(Opcode.None) code.emit(Opcode.Return) } } diff --git a/examples/bad.pork b/examples/bad.pork index 966078c..5b9056a 100644 --- a/examples/bad.pork +++ b/examples/bad.pork @@ -1,5 +1,9 @@ func depth(i: int32) { + if i <= 0 { + return None + } println("Depth: ", i) + depth(i - 1) } export func main() { @@ -11,5 +15,19 @@ export func main() { true } - return println("uhm, bad") + if true { + + } else { + + } + + if false { + + } else { + + } + + depth(500) + + println("uhm, bad") }