What it means. A match expression over a non-sealed type — a primitive, a plain struct, anything with an unbounded instance set — has no default branch. The compiler cannot prove exhaustiveness for open types, so a default is mandatory.
package main
func name(n int) string = n match {
case 1 => "one"
case 2 => "two"
// missing: case _ => ...
}
func main() {
Println(name(1))
}
error[GALA-E0003]: match expression must have a default case
--> e0003.gala:4:5
|
4 | case 1 => "one"
| ^^^^ add `case _ => ...`
|
= hint: add `case _ => ...`
Add a default that produces a sensible fallback:
func name(n int) string = n match {
case 1 => "one"
case 2 => "two"
case _ => "other"
}
If you genuinely want the program to fail on unknown values, say so explicitly. A bare panic(...) is GALA-E0035 — GALA’s form is go_builtins.Panic:
package main
import "martianoff/gala/go_builtins"
func name(n int) string = n match {
case 1 => "one"
case 2 => "two"
case _ => go_builtins.Panic(s"unexpected n: $n")
}
func main() {
Println(name(1))
}
Non-sealed types have unbounded instance sets, so the transpiler cannot verify every value is covered. Without a default, the generated Go would need a synthesized one (usually a runtime panic), hiding the missing branch from the author. Requiring the default in source surfaces the decision where it is made.
If you want the compiler to prove exhaustiveness for you instead, model the value as a sealed type — then you get GALA-E0002 coverage checking and no default is needed.
panic(...) is rejected