soma.cell

E0102: budget_annotation

E0102 budget_annotation — a malformed budget annotation.

A compile-time error of soma check, the checker of the Soma programming language (soma explain E0102).

The rule

The budget annotations capacity(N), max_key_bytes(N), max_value_bytes(N) and max_element_bytes(N) on a memory slot, and max_instances(N) on a state machine, feed the memory proof, so each must carry exactly one non-negative whole number. Anything else (a string such as "50k", a Float, no argument, several arguments) is refused with E0102, because the proof would otherwise silently fall back to the default. Write the number itself, capacity(50000); underscores such as 50_000 are allowed in Int literals.

A program that triggers it

wrong.cell

cell SessionStore {
    face {
        signal remember(token: String, user: String) -> Int
    }
    memory {
        sessions: Map<String, String> [persistent, capacity("50k")]
    }
    on remember(token: String, user: String) {
        sessions.set(token, user)
        return sessions.size
    }
}

What soma check prints:

$ soma check wrong.cell
error: `capacity("50k")` on 'sessions': its argument is not a whole number — the memory proof would silently use the default instead. Write `capacity(N)` with one whole number, or drop it
  --> wrong.cell:6:52
  |
6 |         sessions: Map<String, String> [persistent, capacity("50k")]
  |                                                    ^
  = code: E0102
✗ 1 error(s), 0 warning(s).

The fix field of soma check --json: the memory proof would silently use the default instead. Write `capacity(N)` with one whole number, or drop it

On line 6, sessions: Map<String, String> [persistent, capacity("50k")] becomes sessions: Map<String, String> [persistent, capacity(50000)].

wrong.cell → right.cell

--- wrong.cell
+++ right.cell
@@ -4,5 +4,5 @@
     }
     memory {
-        sessions: Map<String, String> [persistent, capacity("50k")]
+        sessions: Map<String, String> [persistent, capacity(50000)]
     }
     on remember(token: String, user: String) {

With the fix, soma check accepts the program:

$ soma check right.cell
✓ All checks passed.