Source src/silo:std.effects.panic
1##! Panic effect and intrinsic. 2##! 3##! `panic` is a free `:fn` of stack effect `( Str -> Never )` wrapping 4##! the host intrinsic — it is not an effect op. `PanicInfo` captures 5##! a panic as a record of message, location, and backtrace (location 6##! and frames are `Str` placeholders until structured `Location` / 7##! `Frame` types land). 8##! 9##! `+Panic` declares `.catch` and `.resume-unwind`. The host currently 10##! ships only the default abort-on-panic handler, so `.catch` 11##! terminates today; real handler plumbing arrives with the 12##! effect-handler infrastructure. 13 14:use 15 :open core Never Str Vec Result 16:end 17 18# si[impl effect.panic.info+1] 19## Panic payload: message, source location, and a sequence of backtrace 20## frames. `Location` and `Frame` are placeholders (`Str`) pending 21## `spec/reflection.md`'s typed Location and the stdlib `Frame` record. 22:record(pub) PanicInfo 23 .message Str 24 .location Str 25 .stack (Vec Str) 26:end 27 28# si[impl effect.panic.decl+1] 29## Observable-panic effect. `.catch` runs a quotation and reifies a 30## panic into `(Result a PanicInfo)`; `.resume-unwind` re-raises a 31## captured `PanicInfo`. The host default behaviour (abort or unwind) 32## applies when `+Panic` is not in scope. 33:effect(pub) Panic 34 .catch ( [ -> a ] -> (Result a PanicInfo) ) 35 .resume-unwind ( PanicInfo -> Never ) 36:end 37 38# si[impl effect.panic.intrinsic] 39## Free fn wrapping the host `panic` intrinsic. Stack effect 40## `( Str -> Never )`. Because the return type is `Never`, a `panic` 41## call type-checks in any position that expects any type — see the 42## never-coercion rule in `spec/types.md`. 43:fn(pub) panic ( Str -> Never ) panic-intrinsic :end