E0066: scalar_slot
E0066 scalar_slot — a memory slot that is not a Map or a List.
A compile-time error of soma check, the checker of the Soma programming language (soma explain E0066).
The rule
A memory slot must be a Map or a List; a slot declared as a single value such as balance: Int is refused. Slots are keyed stores, and the check makes the declaration match how they behave. Keep a single value as one entry of a Map, for example balance: Map<String, Int> read with balance.get("value").
A program that triggers it
wrong.cell
cell Wallet {
memory {
balance: Int [persistent]
}
on deposit(amount: Int) {
let current = balance.get("value") ?? 0
balance.set("value", current + amount)
return current + amount
}
}What soma check prints:
$ soma check wrong.cell
error: slot 'balance' is declared as Int — a memory slot is a Map<K, V> or a List<T>; keep a single value as one entry: `balance: Map<String, Int>` and `balance.get("value")`
--> wrong.cell:3:9
|
3 | balance: Int [persistent]
| ^
= code: E0066
✗ 1 error(s), 0 warning(s).The fix field of soma check --json: a memory slot is a Map<K, V> or a List<T>; keep a single value as one entry: `balance: Map<String, Int>` and `balance.get("value")`
The fix
On line 3, balance: Int [persistent] becomes balance: Map<String, Int> [persistent].
wrong.cell → right.cell
--- wrong.cell
+++ right.cell
@@ -1,5 +1,5 @@
cell Wallet {
memory {
- balance: Int [persistent]
+ balance: Map<String, Int> [persistent]
}
on deposit(amount: Int) {With the fix, soma check accepts the program:
$ soma check right.cell
✓ All checks passed.