soma.cell

E0001: property_contradiction

E0001 property_contradiction — two properties of one memory slot exclude each other.

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

The rule

Some memory slot properties exclude each other: [persistent] and [ephemeral], [consistent] and [eventual], [immutable] and [evict], [ephemeral] and [retain]. soma check refuses a slot that carries both sides of such a pair, because the storage could not honour both promises. Keep the one property that says what you mean — here, session tokens that need not survive a restart are [ephemeral] only.

A program that triggers it

wrong.cell

cell Sessions {
    memory {
        tokens: Map<String, String> [persistent, ephemeral]
    }
    on login(user: String, token: String) {
        tokens.set(user, token)
    }
    on token_of(user: String) {
        return tokens.get(user) ?? ""
    }
}

What soma check prints:

$ soma check wrong.cell
error: contradictory memory properties on 'tokens': persistent and ephemeral cannot coexist
  --> wrong.cell:3:9
  |
3 |         tokens: Map<String, String> [persistent, ephemeral]
  |         ^
  = code: E0001
✗ 1 error(s), 0 warning(s).

The fix field of soma check --json: Remove either [persistent] or [ephemeral] from memory slot 'tokens'. These properties are mutually exclusive.

On line 3, tokens: Map<String, String> [persistent, ephemeral] becomes tokens: Map<String, String> [ephemeral].

wrong.cell → right.cell

--- wrong.cell
+++ right.cell
@@ -1,5 +1,5 @@
 cell Sessions {
     memory {
-        tokens: Map<String, String> [persistent, ephemeral]
+        tokens: Map<String, String> [ephemeral]
     }
     on login(user: String, token: String) {

With the fix, soma check accepts the program:

$ soma check right.cell
✓ All checks passed.