E0035: slot_method_on_local
E0035 slot_method_on_local — a slot method (.set / .push / .delete) on a local value.
A compile-time error of soma check, the checker of the Soma programming language (soma explain E0035).
The rule
.set() and .delete() used as a value on a local map are refused: they are slot methods and, on a local, they do not return the updated map. Written as a statement (line.set(k, v)), the call does change the local and passes check; it is the expression form (let priced = line.set(…)) that is the error. Write the local with brackets (line["total"] = v) and use the variable itself, or rebuild it (line = without(line, k) to remove a key).
A program that triggers it
wrong.cell
cell Pricing {
face {
signal quote(sku: String, qty: Int) -> Map
}
on quote(sku: String, qty: Int) {
let line = map("sku", sku, "qty", qty)
let priced = line.set("total", qty * 499)
return priced
}
}What soma check prints:
$ soma check wrong.cell
error: `.set()` is a memory-slot method and 'line' is a local — a local map is written with brackets: `line[k] = v`
--> wrong.cell:7:22
|
7 | let priced = line.set("total", qty * 499)
| ^
= code: E0035
✗ 1 error(s), 0 warning(s).The fix field of soma check --json: a local map is written with brackets: `line[k] = v`
The fix
Lines 7–8 are rewritten.
wrong.cell → right.cell
--- wrong.cell
+++ right.cell
@@ -5,6 +5,6 @@
on quote(sku: String, qty: Int) {
let line = map("sku", sku, "qty", qty)
- let priced = line.set("total", qty * 499)
- return priced
+ line["total"] = qty * 499
+ return line
}
}With the fix, soma check accepts the program:
$ soma check right.cell
✓ All checks passed.