E0005: duplicate_cell
E0005 duplicate_cell — two cells share a name.
A compile-time error of soma check, the checker of the Soma programming language (soma explain E0005).
The rule
Two cells in one program may not have the same name; soma check reports "defined twice — rename one; same-named cells are not merged". A second cell Orders { … } is not a continuation of the first, and a call like Orders.place(…) would be ambiguous. Rename one of the cells, or move its handlers into the other.
A program that triggers it
wrong.cell
cell Orders {
memory {
orders: Map<String, Int> [persistent]
}
on place(id: String, total: Int) {
orders.set(id, total)
}
}
cell Orders {
on summary() {
return "orders"
}
}What soma check prints:
$ soma check wrong.cell
error: cell 'Orders' is defined twice — rename one; same-named cells are not merged
--> wrong.cell:10:1
|
10 | cell Orders {
| ^
= code: E0005
✗ 1 error(s), 0 warning(s).The fix field of soma check --json: rename one; same-named cells are not merged
The fix
On line 10, cell Orders { becomes cell Reports {.
wrong.cell → right.cell
--- wrong.cell
+++ right.cell
@@ -8,5 +8,5 @@
}
-cell Orders {
+cell Reports {
on summary() {
return "orders"With the fix, soma check accepts the program:
$ soma check right.cell
✓ All checks passed.