soma.cell

E0069: reserved_handler

E0069 reserved_handler — a handler named like a reserved builtin.

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

The rule

A handler may not take the name of a builtin the proofs and safety gates rest on: transition, approve, fail, get_status, has_state, valid_transitions, think, think_json, set_budget, tokens_used. Such a handler would replace the builtin for every bare call in the program, state machines included. Rename the handler (for example record_move) and call it next to the builtin.

A program that triggers it

wrong.cell

cell Tickets {
    memory {
        log: List<String> [persistent]
    }
    state ticket {
        initial: open
        open -> closed
    }
    on transition(id: String, to: String) {
        log.push("ticket {id} -> {to}")
    }
    on close(id: String) { transition(id, "closed") }
}

What soma check prints:

$ soma check wrong.cell
error: a handler cannot be named `transition`: it would replace the builtin transition() for every bare call in the program (state machines, approvals and errors included) — rename it (`on transition_tickets(…)`)
  --> wrong.cell:9:5
  |
9 |     on transition(id: String, to: String) {
  |     ^
  = code: E0069
✗ 1 error(s), 0 warning(s).

The fix field of soma check --json: rename it (`on transition_tickets(…)`)

On line 9, on transition(id: String, to: String) { becomes on record_move(id: String, to: String) {; line 12 is rewritten.

wrong.cell → right.cell

--- wrong.cell
+++ right.cell
@@ -7,7 +7,10 @@
         open -> closed
     }
-    on transition(id: String, to: String) {
+    on record_move(id: String, to: String) {
         log.push("ticket {id} -> {to}")
     }
-    on close(id: String) { transition(id, "closed") }
+    on close(id: String) {
+        transition(id, "closed")
+        record_move(id, "closed")
+    }
 }

With the fix, soma check accepts the program:

$ soma check right.cell
✓ All checks passed.