E1001: expected
E1001 expected — the parser expected one token and found another.
A compile-time error of soma check, the checker of the Soma programming language (soma explain E1001).
The rule
E1001 is the parser's general syntax error: at some point it needed one specific token and found another, and the message names both (here expected ')', found 'return'). The position it points at is where the parser noticed the problem, which is often the line after the real mistake, so look just before it. Fix it by adding or correcting the token the message names, here the closing parenthesis of balances.set(...).
A program that triggers it
wrong.cell
cell Wallet {
memory {
balances: Map<String, Int> [persistent]
}
on deposit(owner: String, amount: Int) {
let current = balances.get(owner) ?? 0
balances.set(owner, current + amount
return current + amount
}
}What soma check prints:
$ soma check wrong.cell
error: expected ')', found 'return'
--> wrong.cell:8:9
|
8 | return current + amount
| ^
= code: E1001The fix
On line 7, balances.set(owner, current + amount becomes balances.set(owner, current + amount).
wrong.cell → right.cell
--- wrong.cell
+++ right.cell
@@ -5,5 +5,5 @@
on deposit(owner: String, amount: Int) {
let current = balances.get(owner) ?? 0
- balances.set(owner, current + amount
+ balances.set(owner, current + amount)
return current + amount
}With the fix, soma check accepts the program:
$ soma check right.cell
✓ All checks passed.