E0029: function_as_value
E0029 function_as_value — a handler or builtin used as a value instead of being called.
A compile-time error of soma check, the checker of the Soma programming language (soma explain E0029).
The rule
A handler or builtin name is not a value in Soma: map(with_tax) passes a bare name where a function value is needed, and soma check refuses it. Functions passed as arguments are lambdas. Wrap the call in a lambda, map(c => with_tax(c)).
A program that triggers it
wrong.cell
cell Prices {
on with_tax(cents: Int) {
return cents + idiv(cents * 20, 100)
}
on all_with_tax(items: List<Int>) {
return items |> map(with_tax)
}
}What soma check prints:
$ soma check wrong.cell
error: `with_tax` is a function, not a value — pass a lambda (`x => with_tax(x)`) or call it (`with_tax(…)`)
--> wrong.cell:6:29
|
6 | return items |> map(with_tax)
| ^
= code: E0029
✗ 1 error(s), 0 warning(s).The fix field of soma check --json: pass a lambda (`x => with_tax(x)`) or call it (`with_tax(…)`)
The fix
On line 6, return items |> map(with_tax) becomes return items |> map(c => with_tax(c)).
wrong.cell → right.cell
--- wrong.cell
+++ right.cell
@@ -4,5 +4,5 @@
}
on all_with_tax(items: List<Int>) {
- return items |> map(with_tax)
+ return items |> map(c => with_tax(c))
}
}With the fix, soma check accepts the program:
$ soma check right.cell
✓ All checks passed.