E0010: promise_violation
E0010 promise_violation — the cell breaks a promise of its face.
A compile-time error of soma check, the checker of the Soma programming language (soma explain E0010).
The rule
A structural promise in a cell's face (all_persistent, all_consistent, all_encrypted, has_memory, has_face, has_signals, has_auth) is checked against the cell's structure. promise all_persistent requires every memory slot to be marked [persistent]; one [ephemeral] slot breaks it. The message does not name the offending slot, so look at each slot's properties, then mark it [persistent] or remove the promise.
A program that triggers it
wrong.cell
cell Ledger {
face {
promise all_persistent
signal post(account: String, cents: Int) -> Int
}
memory {
balances: Map<String, Int> [persistent, consistent]
recent: Map<String, Int> [ephemeral]
}
on post(account: String, cents: Int) {
let total = (balances.get(account) ?? 0) + cents
balances.set(account, total)
recent.set(account, cents)
return total
}
}What soma check prints:
$ soma check wrong.cell
error: structural promise violated in cell 'Ledger': promise 'all_persistent' is not satisfied
--> wrong.cell:3:17
|
3 | promise all_persistent
| ^
= code: E0010
✗ 1 error(s), 0 warning(s).The fix field of soma check --json: Cell 'Ledger' violates promise 'all_persistent'. Either satisfy the constraint or remove the promise from the face section.
The fix
On line 8, recent: Map<String, Int> [ephemeral] becomes recent: Map<String, Int> [persistent].
wrong.cell → right.cell
--- wrong.cell
+++ right.cell
@@ -6,5 +6,5 @@
memory {
balances: Map<String, Int> [persistent, consistent]
- recent: Map<String, Int> [ephemeral]
+ recent: Map<String, Int> [persistent]
}
on post(account: String, cents: Int) {With the fix, soma check accepts the program:
$ soma check right.cell
✓ All checks passed.