soma.cell

E0085: interpolation_malformed

E0085 interpolation_malformed — an interpolation that does not parse.

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

The rule

An interpolation that starts like code but does not parse, such as {len(items}, is refused; otherwise it would print literally. Fix the expression (here the missing )), or write {{...}} when you want literal braces.

A program that triggers it

wrong.cell

cell Receipt {
    on summary(customer: String, items: List<String>) {
        return "{customer} bought {len(items} items"
    }
}

What soma check prints:

$ soma check wrong.cell
error: string interpolation `{len(items}` is not an expression — it would print literally; fix it, or write `{{…}}` for literal braces
  --> wrong.cell:3:16
  |
3 |         return "{customer} bought {len(items} items"
  |                ^
  = code: E0085
✗ 1 error(s), 0 warning(s).

The fix field of soma check --json: it would print literally; fix it, or write `{{…}}` for literal braces

On line 3, return "{customer} bought {len(items} items" becomes return "{customer} bought {len(items)} items".

wrong.cell → right.cell

--- wrong.cell
+++ right.cell
@@ -1,5 +1,5 @@
 cell Receipt {
     on summary(customer: String, items: List<String>) {
-        return "{customer} bought {len(items} items"
+        return "{customer} bought {len(items)} items"
     }
 }

With the fix, soma check accepts the program:

$ soma check right.cell
✓ All checks passed.