E0073: pipe_right_side
E0073 pipe_right_side — the right side of |> is not a call.
A compile-time error of soma check, the checker of the Soma programming language (soma explain E0073).
The rule
The right side of |> must be a call: x |> f(a) means f(x, a). In prices |> sum() * 1.2 the right side is the product sum() * 1.2, not a call, so check refuses it (and also reports sum() called with no argument). Parenthesise the pipe before combining its result: (prices |> sum()) * 1.2.
A program that triggers it
wrong.cell
cell Invoice {
on total_with_tax(prices: List<Float>) {
let total = prices |> sum() * 1.2
return total
}
}What soma check prints:
$ soma check wrong.cell
error: the right side of `|>` must be a call — `x |> f(a)` means f(x, a); to combine the result, parenthesise: `(x |> f()) + 1`
--> wrong.cell:3:31
|
3 | let total = prices |> sum() * 1.2
| ^
= code: E0073
error: sum() needs at least 1 argument (0 given) — sum(list: List) -> Int|Float
--> wrong.cell:3:31
|
3 | let total = prices |> sum() * 1.2
| ^
= code: E0101
✗ 2 error(s), 0 warning(s).The fix field of soma check --json: `x |> f(a)` means f(x, a); to combine the result, parenthesise: `(x |> f()) + 1`
The fix
On line 3, let total = prices |> sum() * 1.2 becomes let total = (prices |> sum()) * 1.2.
wrong.cell → right.cell
--- wrong.cell
+++ right.cell
@@ -1,5 +1,5 @@
cell Invoice {
on total_with_tax(prices: List<Float>) {
- let total = prices |> sum() * 1.2
+ let total = (prices |> sum()) * 1.2
return total
}With the fix, soma check accepts the program:
$ soma check right.cell
✓ All checks passed.