E0106: argument_count
E0106 argument_count — a handler called with the wrong number of arguments.
A compile-time error of soma check, the checker of the Soma programming language (soma explain E0106).
The rule
transition() takes 2 arguments (the instance id and the target state) or 3 (the id, the source state and the target state); with any other count soma check reports E0106, and this binary reports the same call a second time as E0101 (builtin arity). The first argument is the id of one instance, such as an order, not the machine's name, so transition("shipped") has lost it. Pass the id: transition(order_id, "shipped"). A call to your own handler with the wrong number of arguments is reported as E0012 (dispatch), not as E0106.
A program that triggers it
wrong.cell
cell Orders {
face {
signal ship(order_id: String) -> String
}
state order {
initial: placed
placed -> paid
paid -> shipped
}
on ship(order_id: String) {
transition("shipped")
return get_status(order_id)
}
}What soma check prints:
$ soma check wrong.cell
error: transition() needs at least 2 arguments (1 given) — transition(id, target_state: String) -> {id, from, to} | transition(id, from_state: String, to_state: String) -> {id, from, to}
--> wrong.cell:11:9
|
11 | transition("shipped")
| ^
= code: E0101
error: transition() takes 2 arguments (instance id, target state) or 3 (instance id, source state, target state), got 1 — `transition(id, "shipped")` or `transition(id, "paid", "shipped")`
--> wrong.cell:11:9
|
11 | transition("shipped")
| ^
= code: E0106
✗ 2 error(s), 0 warning(s).The fix field of soma check --json: `transition(id, "shipped")` or `transition(id, "paid", "shipped")`
The fix
On line 11, transition("shipped") becomes transition(order_id, "shipped").
wrong.cell → right.cell
--- wrong.cell
+++ right.cell
@@ -9,5 +9,5 @@
}
on ship(order_id: String) {
- transition("shipped")
+ transition(order_id, "shipped")
return get_status(order_id)
}With the fix, soma check accepts the program:
$ soma check right.cell
✓ All checks passed.