E0097: empty_match
E0097 empty_match — a match with no arm.
A compile-time error of soma check, the checker of the Soma programming language (soma explain E0097).
The rule
A match with no arms evaluates to () whatever the subject is, so a placeholder left as match zone { } would quietly give () to everything after it; soma check refuses it with E0097. Write the arms (pattern -> value), and end with a _ -> … arm when the listed patterns do not cover every value.
A program that triggers it
wrong.cell
cell Shipping {
face {
signal fee(zone: String, weight_kg: Int) -> Int
}
on fee(zone: String, weight_kg: Int) {
let base = match zone {
// TODO: domestic, eu, world
}
return base + weight_kg * 50
}
}What soma check prints:
$ soma check wrong.cell
error: `match` with no arms always evaluates to `()` — add at least one arm (`_ -> …`)
--> wrong.cell:6:20
|
6 | let base = match zone {
| ^
= code: E0097
✗ 1 error(s), 0 warning(s).The fix field of soma check --json: add at least one arm (`_ -> …`)
The fix
Line 7 is rewritten.
wrong.cell → right.cell
--- wrong.cell
+++ right.cell
@@ -5,5 +5,7 @@
on fee(zone: String, weight_kg: Int) {
let base = match zone {
- // TODO: domestic, eu, world
+ "domestic" -> 500
+ "eu" -> 900
+ _ -> 1500
}
return base + weight_kg * 50With the fix, soma check accepts the program:
$ soma check right.cell
✓ All checks passed.