soma.cell

E0087: interior_timer

E0087 interior_timer — every / after in an interior cell.

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

The rule

An every or after block inside an interior cell never runs: interior cells run only through the runtime section of soma run, and soma serve does not schedule their timers. Timers run in top-level cells, so move the timer to a top-level cell; here the cell that owns the queue is made top-level together with its every block.

A program that triggers it

wrong.cell

cell Warehouse {
    interior {
        cell Picker {
            face { signal pick(sku: String) }
            memory {
                queue: List<String> [persistent]
            }
            on pick(sku: String) {
                queue.push(sku)
            }
            every 5min {
                print("queue length {queue.len}")
            }
        }
    }
    runtime { signal pick("sku-42") }
}

What soma check prints:

$ soma check wrong.cell
error: `every` block in the interior cell Warehouse.Picker never runs: interior cells run only through the runtime section of `soma run` (one pass), and `soma serve` does not schedule them — move the `every` block to a top-level cell (timers run in any top-level cell under `soma serve`) and have it call or `signal` what it needs
  --> wrong.cell:11:13
   |
11 |             every 5min {
   |             ^
  = code: E0087
✗ 1 error(s), 0 warning(s).

The fix field of soma check --json: move the `every` block to a top-level cell (timers run in any top-level cell under `soma serve`) and have it call or `signal` what it needs

Lines 1–14 are rewritten; line 16 is rewritten.

wrong.cell → right.cell

--- wrong.cell
+++ right.cell
@@ -1,17 +1,11 @@
-cell Warehouse {
-    interior {
-        cell Picker {
-            face { signal pick(sku: String) }
-            memory {
-                queue: List<String> [persistent]
-            }
-            on pick(sku: String) {
-                queue.push(sku)
-            }
-            every 5min {
-                print("queue length {queue.len}")
-            }
-        }
+cell Picker {
+    memory {
+        queue: List<String> [persistent]
     }
-    runtime { signal pick("sku-42") }
+    on pick(sku: String) {
+        queue.push(sku)
+    }
+    every 5min {
+        print("queue length {queue.len}")
+    }
 }

With the fix, soma check accepts the program:

$ soma check right.cell
✓ All checks passed.