W0001: unhandled_signal
W0001 unhandled_signal — an emitted signal no cell handles.
A warning of soma check, the checker of the Soma programming language (soma explain W0001).
The rule
Inside an interior block, soma check warns with W0001 when a cell's face declares a signal that no sibling cell handles and no cell awaits; the message says the signal "will be lost". In this compiler the warning comes together with error E0003, because a face signal must also have an on handler in its own cell. Add the missing handler (on cancel(id: String) { … }) or remove the signal from the face. An emit of an event nobody handles is a different diagnostic: it is reported as W0011.
A program that triggers it
wrong.cell
cell Shop {
interior {
cell Orders {
face {
signal place(id: String, total: Int)
signal cancel(id: String)
}
memory {
orders: Map<String, Int> [persistent]
}
on place(id: String, total: Int) {
orders.set(id, total)
return id
}
}
}
}What soma check prints:
$ soma check wrong.cell
warning: signal 'cancel' emitted by 'Orders' has no handler (signal will be lost)
--> wrong.cell:6:17
|
6 | signal cancel(id: String)
| ^
error: face contract: signal 'cancel' declared in cell 'Orders' has no handler
--> wrong.cell:6:17
|
6 | signal cancel(id: String)
| ^
= code: E0003
✗ 1 error(s), 1 warning(s).The fix field of soma check --json: Add a handler 'on cancel(...)' to cell 'Orders', or remove the emit if it's unused.
The fix
4 lines are added after line 14.
wrong.cell → right.cell
--- wrong.cell
+++ right.cell
@@ -13,4 +13,8 @@
return id
}
+ on cancel(id: String) {
+ orders.delete(id)
+ return id
+ }
}
}With the fix, soma check accepts the program:
$ soma check right.cell
✓ All checks passed.