E0023: dead_code
E0023 dead_code — statements that can never run.
A compile-time error of soma check, the checker of the Soma programming language (soma explain E0023).
The rule
Adjacent string literals do not concatenate in Soma: in return "a " "b" the second literal is a separate statement after return and never runs. soma check reports this case as an error (other code after a return is only a warning). Write one literal and interpolate the values into it, or join strings with +.
A program that triggers it
wrong.cell
cell Notifications {
on shipping_notice(order_id: String, carrier: String) {
return "Order {order_id} has shipped " "with {carrier}."
}
}What soma check prints:
$ soma check wrong.cell
error: in Notifications.shipping_notice: a string literal follows `return` and is never evaluated — adjacent string literals do not concatenate. Write one literal, or interpolate: "hello {name}"
--> wrong.cell:3:48
|
3 | return "Order {order_id} has shipped " "with {carrier}."
| ^
= code: E0023
✗ 1 error(s), 0 warning(s).The fix field of soma check --json: in Notifications.shipping_notice: a string literal follows `return` and is never evaluated — adjacent string literals do not concatenate. Write one literal, or interpolate: "hello {name}"
The fix
On line 3, return "Order {order_id} has shipped " "with {carrier}." becomes return "Order {order_id} has shipped with {carrier}.".
wrong.cell → right.cell
--- wrong.cell
+++ right.cell
@@ -1,5 +1,5 @@
cell Notifications {
on shipping_notice(order_id: String, carrier: String) {
- return "Order {order_id} has shipped " "with {carrier}."
+ return "Order {order_id} has shipped with {carrier}."
}
}With the fix, soma check accepts the program:
$ soma check right.cell
✓ All checks passed.