soma.cell

E0096: empty_program

E0096 empty_program — a file with no cell.

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

The rule

A Soma program is made of cells, and soma check refuses a file that holds no cell at all (only comments, or a cell left commented out) with E0096 instead of passing a file that defines nothing. The diagnostic has no line number, since there is nothing to point at. Put the code in a cell: memory, a face that declares each signal, and an on handler per signal.

A program that triggers it

wrong.cell

// Inventory service
//
// stock:   sku -> units on hand
// restock: add units to a sku, return the new count
//
// on restock(sku: String, qty: Int) {
//     let n = (stock.get(sku) ?? 0) + qty
//     stock.set(sku, n)
//     return n
// }

What soma check prints:

$ soma check wrong.cell
error: no cell in this file — a program is at least `cell Name { on run() { … } }`
  = code: E0096
✗ 1 error(s), 0 warning(s).

The fix field of soma check --json: a program is at least `cell Name { on run() { … } }`

Lines 5–10 are rewritten.

wrong.cell → right.cell

--- wrong.cell
+++ right.cell
@@ -3,8 +3,15 @@
 // stock:   sku -> units on hand
 // restock: add units to a sku, return the new count
-//
-// on restock(sku: String, qty: Int) {
-//     let n = (stock.get(sku) ?? 0) + qty
-//     stock.set(sku, n)
-//     return n
-// }
+cell Inventory {
+    face {
+        signal restock(sku: String, qty: Int) -> Int
+    }
+    memory {
+        stock: Map<String, Int> [persistent]
+    }
+    on restock(sku: String, qty: Int) {
+        let n = (stock.get(sku) ?? 0) + qty
+        stock.set(sku, n)
+        return n
+    }
+}

With the fix, soma check accepts the program:

$ soma check right.cell
✓ All checks passed.