soma.cell

E0063: state_annotation

E0063 state_annotation — an unknown annotation on a state or transition.

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

The rule

A state machine accepts exactly one annotation, max_instances(N); any other name in the brackets is reported as read by nothing, with a suggestion when it is close to max_instances. Without this check a misspelled [max_instance(1000)] would sit there silently while the machine kept its default bound. Fix the spelling to max_instances(N) or remove the annotation.

A program that triggers it

wrong.cell

cell Orders {
    memory {
        orders: Map<String, String> [persistent]
    }
    state order [max_instance(1000)] {
        initial: placed
        placed -> shipped
        shipped -> delivered
    }
    on place(id: String, item: String) {
        orders.set(id, item)
        return id
    }
    on ship(id: String) { transition(id, "shipped") }
    on deliver(id: String) { transition(id, "delivered") }
}

What soma check prints:

$ soma check wrong.cell
error: `[max_instance]` on state machine 'order' is read by nothing — did you mean `max_instances(N)`? — `max_instances(N)` is the only annotation a state machine takes
  --> wrong.cell:5:18
  |
5 |     state order [max_instance(1000)] {
  |                  ^
  = code: E0063
✗ 1 error(s), 0 warning(s).

The fix field of soma check --json: did you mean `max_instances(N)`?

On line 5, state order [max_instance(1000)] { becomes state order [max_instances(1000)] {.

wrong.cell → right.cell

--- wrong.cell
+++ right.cell
@@ -3,5 +3,5 @@
         orders: Map<String, String> [persistent]
     }
-    state order [max_instance(1000)] {
+    state order [max_instances(1000)] {
         initial: placed
         placed -> shipped

With the fix, soma check accepts the program:

$ soma check right.cell
✓ All checks passed.