compiler: allow deferred panic

This is rare, but apparently some programs do this:

    defer panic("...")

This is emitted in the IR as a builtin function.
This commit is contained in:
Ayke van Laethem
2024-10-31 09:18:32 +01:00
committed by Ayke
parent 058f62ac08
commit 449eefdb19
3 changed files with 23 additions and 0 deletions
+4
View File
@@ -1680,6 +1680,10 @@ func (b *builder) createBuiltin(argTypes []types.Type, argValues []llvm.Value, c
result = b.CreateSelect(cmp, result, arg, "")
}
return result, nil
case "panic":
// This is rare, but happens in "defer panic()".
b.createRuntimeInvoke("_panic", argValues, "")
return llvm.Value{}, nil
case "print", "println":
for i, value := range argValues {
if i >= 1 && callName == "println" {