E0037: runtime_signal_args
E0037 runtime_signal_args — the runtime section sends a signal with the wrong arguments.
A compile-time error of soma check, the checker of the Soma programming language (soma explain E0037).
The rule
A signal line in the runtime { } section must pass as many arguments as the interior handler of that name takes, and a literal argument must match the declared parameter type. Here a String literal is passed where the handler declares an Int, which would fail when soma run sends the signal. Pass a value of the declared type, for example an Int amount in cents instead of the text "49.99".
A program that triggers it
wrong.cell
cell Shop {
interior {
cell Orders {
face {
signal order_placed(order_id: String, cents: Int)
}
on order_placed(order_id: String, cents: Int) {
print("order {order_id}: {cents} cents")
}
}
}
runtime {
signal order_placed("ord-1", "49.99")
}
}What soma check prints:
$ soma check wrong.cell
error: `signal order_placed(…)`: parameter 'cents' of Orders.order_placed is Int, and the runtime section passes a String literal
--> wrong.cell:13:38
|
13 | signal order_placed("ord-1", "49.99")
| ^
= code: E0037
✗ 1 error(s), 0 warning(s).The fix field of soma check --json: `signal order_placed(…)`: parameter 'cents' of Orders.order_placed is Int, and the runtime section passes a String literal
The fix
On line 13, signal order_placed("ord-1", "49.99") becomes signal order_placed("ord-1", 4999).
wrong.cell → right.cell
--- wrong.cell
+++ right.cell
@@ -11,5 +11,5 @@
}
runtime {
- signal order_placed("ord-1", "49.99")
+ signal order_placed("ord-1", 4999)
}
}With the fix, soma check accepts the program:
$ soma check right.cell
✓ All checks passed.