E0014: unmatched_handler
E0014 unmatched_handler — a handler answers a signal the face does not declare.
A compile-time error of soma check, the checker of the Soma programming language (soma explain E0014).
The rule
In an interior block, a cell's on handler is expected to answer a signal that a sibling declares (or that the parent emits). A handler for order_created when the only sibling signal is order_placed would never be called, so soma check reports it as an unmatched handler. Rename the handler to the signal a sibling sends, or add the signal to the sibling's face.
A program that triggers it
wrong.cell
cell Shop {
interior {
cell Checkout {
face {
signal order_placed(order_id: String, total: Int)
}
on order_placed(order_id: String, total: Int) {
return order_id
}
}
cell Fulfillment {
memory {
queue: List<String> [persistent]
}
on order_created(order_id: String, total: Int) {
queue.push(order_id)
}
}
}
}What soma check prints:
$ soma check wrong.cell
error: unmatched handler: cell 'Fulfillment' handles signal 'order_created' but no sibling emits it
--> wrong.cell:15:13
|
15 | on order_created(order_id: String, total: Int) {
| ^
= code: E0014
✗ 1 error(s), 0 warning(s).The fix field of soma check --json: unmatched handler: cell 'Fulfillment' handles signal 'order_created' but no sibling emits it
The fix
On line 15, on order_created(order_id: String, total: Int) { becomes on order_placed(order_id: String, total: Int) {.
wrong.cell → right.cell
--- wrong.cell
+++ right.cell
@@ -13,5 +13,5 @@
queue: List<String> [persistent]
}
- on order_created(order_id: String, total: Int) {
+ on order_placed(order_id: String, total: Int) {
queue.push(order_id)
}With the fix, soma check accepts the program:
$ soma check right.cell
✓ All checks passed.