Skip to main content

Module panic

Module panic 

Source
Expand description

Go panics, carried on Rust unwinding.

A Go panic becomes a Rust unwind whose payload is a GoPanic. Runtime errors (division by zero, bounds, nil dereference, …) use the same payload with gc’s exact text, because programs and tests match on it.

For now the payload holds only the text gc prints after panic: . From M1, when interfaces exist, it carries the panic value as an any, so recover can hand it back and runtime errors satisfy runtime.Error.

Structs§

GoPanic
Payload of a Rust unwind that implements a Go panic: the value recover hands back, and the text gc prints after panic: .

Enums§

RuntimeError
The runtime errors generated code can raise.

Functions§

begin
Takes over a caught panic so the deferred calls can recover it.
go_panic
Starts a Go panic.
init_runtime_errors
Teaches the runtime the ids of Error() string and String() string, so a recovered runtime error satisfies error like gc’s does. Generated main calls this before anything else.
panic_custom
panic(v) for a value of a named type with a predeclared underlying type, printed as gc’s printanycustomtype does: main.T(5), main.S("x").
panic_iface
panic(v) where the value is an interface: its type descriptor knows how gc prints it (an error prints Error(), a named basic type prints main.T(v), and so on).
panic_nil
panic(nil).
panic_value
panic(v) for a value of a predeclared type, printed as gc’s printpanicval does: like print, with newlines in strings followed by a tab.
recover
recover(): the value of the panic being handled, and an end to it.
recovered
Whether the panic being handled was recovered.
resume
Carries on unwinding with the panic being handled.
runtime_error
Raises a Go runtime error.