E0053: transition_effect
E0053 transition_effect — an effect block on a transition does something it may not.
A compile-time error of soma check, the checker of the Soma programming language (soma explain E0053).
The rule
A transition in a state section carries an effect { … } block. The 3.1.0 runtime parses that block but never runs it, so its writes would silently not happen; soma check refuses any such block. Move the work into the handler, right after its transition() call.
A program that triggers it
wrong.cell
cell Orders {
memory {
shipped_count: Map<String, Int> [persistent]
}
state order {
initial: paid
paid -> shipped {
effect {
shipped_count.set("all", (shipped_count.get("all") ?? 0) + 1)
}
}
}
on ship(id: String) {
transition(id, "shipped")
return id
}
}What soma check prints:
$ soma check wrong.cell
error: the transition paid -> shipped has an `effect { … }` block, which this runtime does not run — do that work in the handler, right after its transition()
--> wrong.cell:9:17
|
9 | shipped_count.set("all", (shipped_count.get("all") ?? 0) + 1…
| ^
= code: E0053
✗ 1 error(s), 0 warning(s).The fix field of soma check --json: do that work in the handler, right after its transition()
The fix
Lines 7–11 are rewritten; 1 line is added after line 14.
wrong.cell → right.cell
--- wrong.cell
+++ right.cell
@@ -5,12 +5,9 @@
state order {
initial: paid
- paid -> shipped {
- effect {
- shipped_count.set("all", (shipped_count.get("all") ?? 0) + 1)
- }
- }
+ paid -> shipped
}
on ship(id: String) {
transition(id, "shipped")
+ shipped_count.set("all", (shipped_count.get("all") ?? 0) + 1)
return id
}With the fix, soma check accepts the program:
$ soma check right.cell
✓ All checks passed.