soma.cell

E0032: undefined_function

E0032 undefined_function — a call to a name that is neither a handler nor a builtin.

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

The rule

A rule in a cell test calls a function that no cell of the program defines as a handler and that is not a builtin. Soma reports it at check time because the call would otherwise only fail when soma test runs the rule. Call the handler by the name the program gives it, or define the missing handler. In 3.1.0 this code is used for calls inside test rules; the same mistake inside a handler body is reported as E0012.

A program that triggers it

wrong.cell

cell Cart {
    face {
        signal total(prices: List<Int>) -> Int
    }
    on total(prices: List<Int>) {
        return sum(prices)
    }
}

cell test CartTests {
    rules {
        assert cart_total([250, 100]) == 350
    }
}

What soma check prints:

$ soma check wrong.cell
error: test rule calls undefined function 'cart_total' — no cell defines a handler of that name and it is not a builtin
  --> wrong.cell:12:9
   |
12 |         assert cart_total([250, 100]) == 350
   |         ^
  = code: E0032
✗ 1 error(s), 0 warning(s).

The fix field of soma check --json: no cell defines a handler of that name and it is not a builtin

On line 12, assert cart_total([250, 100]) == 350 becomes assert total([250, 100]) == 350.

wrong.cell → right.cell

--- wrong.cell
+++ right.cell
@@ -10,5 +10,5 @@
 cell test CartTests {
     rules {
-        assert cart_total([250, 100]) == 350
+        assert total([250, 100]) == 350
     }
 }

With the fix, soma check accepts the program:

$ soma check right.cell
✓ All checks passed.