E0012: dispatch
E0012 dispatch — a call resolves to no handler, to several, or with the wrong argument count.
A compile-time error of soma check, the checker of the Soma programming language (soma explain E0012).
The rule
A bare call must resolve to exactly one handler with that argument count. When two cells define pack, a third cell's pack(id) is ambiguous, and soma check asks you to qualify it rather than pick one silently. Write Warehouse.pack(id) (or rename one handler); the same code covers a call to a handler with the wrong number of arguments and a call to a name nothing defines.
A program that triggers it
wrong.cell
cell Orders {
memory {
packed: Map<String, Bool> [persistent]
}
on pack(id: String) {
packed.set(id, true)
}
}
cell Warehouse {
memory {
shelves: Map<String, String> [persistent]
}
on pack(id: String) {
shelves.set(id, "packing")
}
}
cell Shipping {
on ship(id: String) {
pack(id)
return "shipped {id}"
}
}What soma check prints:
$ soma check wrong.cell
error: ambiguous call 'pack': defined by cells Orders and Warehouse — qualify it (`Orders.pack(…)`) or rename one handler
--> wrong.cell:21:9
|
21 | pack(id)
| ^
= code: E0012
✗ 1 error(s), 0 warning(s).The fix field of soma check --json: Define the missing handler, fix the spelling, or rename one of the colliding handlers so the call resolves to exactly one cell.
The fix
On line 21, pack(id) becomes Warehouse.pack(id).
wrong.cell → right.cell
--- wrong.cell
+++ right.cell
@@ -19,5 +19,5 @@
cell Shipping {
on ship(id: String) {
- pack(id)
+ Warehouse.pack(id)
return "shipped {id}"
}With the fix, soma check accepts the program:
$ soma check right.cell
✓ All checks passed.