soma.cell

E0011: interpolation_undefined

E0011 interpolation_undefined — a string interpolation names a variable that is not in scope.

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

The rule

Every {name} inside a string literal is interpolated, and soma check refuses one whose name is not a let, parameter, loop variable, match binding or memory slot in scope — here the typo custmer, for which it suggests customer. Without this check the misspelling would only fail when the handler runs. Fix the spelling or bind the name first; for literal braces write {{ and }}. With this binary the same code E0011 is also given to an undefined name outside any string.

A program that triggers it

wrong.cell

cell Invoices {
    memory {
        totals: Map<String, Int> [persistent]
    }
    on issue(customer: String, cents: Int) {
        totals.set(customer, cents)
        return "Invoice for {custmer}: {cents} cents"
    }
}

What soma check prints:

$ soma check wrong.cell
error: string interpolation references undefined variable 'custmer' (did you mean 'customer'?) — define it before this line, or escape literal braces as '{{custmer}}'
  --> wrong.cell:7:16
  |
7 |         return "Invoice for {custmer}: {cents} cents"
  |                ^
  = code: E0011
✗ 1 error(s), 0 warning(s).

The fix field of soma check --json: Bind the name before it is used or fix its spelling — inside a string, escape the braces as '{{...}}' if the text is literal.

On line 7, return "Invoice for {custmer}: {cents} cents" becomes return "Invoice for {customer}: {cents} cents".

wrong.cell → right.cell

--- wrong.cell
+++ right.cell
@@ -5,5 +5,5 @@
     on issue(customer: String, cents: Int) {
         totals.set(customer, cents)
-        return "Invoice for {custmer}: {cents} cents"
+        return "Invoice for {customer}: {cents} cents"
     }
 }

With the fix, soma check accepts the program:

$ soma check right.cell
✓ All checks passed.