E0075: no_initial_state
E0075 no_initial_state — a state machine without initial:.
A compile-time error of soma check, the checker of the Soma programming language (soma explain E0075).
The rule
A state machine needs a start state. Check reports this code for a machine with no initial: line and no transitions; when initial: is missing but the first edge has an ordinary source state, the binary takes that state as the start instead of reporting this code. Add initial: <state> as the first line of the machine.
A program that triggers it
wrong.cell
cell Shipment {
memory {
parcels: Map<String, String> [persistent]
}
state delivery {
}
on register(id: String, address: String) {
parcels.set(id, address)
return id
}
}What soma check prints:
$ soma check wrong.cell
error: state machine 'delivery' has no start state — add `initial: state` as its first line
--> wrong.cell:5:5
|
5 | state delivery {
| ^
= code: E0075
✗ 1 error(s), 0 warning(s).The fix field of soma check --json: add `initial: state` as its first line
The fix
1 line is added after line 5.
wrong.cell → right.cell
--- wrong.cell
+++ right.cell
@@ -4,4 +4,5 @@
}
state delivery {
+ initial: registered
}
on register(id: String, address: String) {With the fix, soma check accepts the program:
$ soma check right.cell
✓ All checks passed.