E0119: flesh
E0119 flesh — a flesh body that cannot go into a skeleton: no skeleton of that name, a second body for one signal, parameters that differ from the signal's, or a helper with an untyped parameter.
A compile-time error of soma check, the checker of the Soma programming language (soma explain E0119).
The rule
A flesh block holds the bodies of a skeleton of the same name, and each body must fit its signal: same parameter names in the same order, with the types taken from the signal. soma check reports E0119 for a flesh whose parameters differ from the signal's (here amount instead of cents), a flesh with no skeleton of that name, a second body for one signal, or a private helper with an untyped parameter. Write the parameters exactly as the signal names them, on deposit(owner, cents); soma skeleton app.cell Wallet.deposit prints the brief with the signature to copy.
A program that triggers it
wrong.cell
skeleton Wallet {
memory {
balances: Map<String, Int> [persistent]
invariant balances >= 0
}
face {
signal balance(owner: String) -> Int reads balances
signal deposit(owner: String, cents: Int) -> Int writes balances
}
}
flesh Wallet {
on balance(owner) { return balances.get(owner) ?? 0 }
on deposit(owner, amount) {
let total = (balances.get(owner) ?? 0) + amount
balances.set(owner, total)
return total
}
}What soma check prints:
$ soma check wrong.cell
error: flesh `on deposit(owner, amount)` does not match the skeleton's `signal deposit(owner: String, cents: Int)` — write `on deposit(owner, cents)`
--> wrong.cell:14:5
|
14 | on deposit(owner, amount) {
| ^
= code: E0119
✗ 1 error(s), 0 warning(s).The fix field of soma check --json: write `on deposit(owner, cents)`
The fix
Lines 14–15 are rewritten.
wrong.cell → right.cell
--- wrong.cell
+++ right.cell
@@ -12,6 +12,6 @@
flesh Wallet {
on balance(owner) { return balances.get(owner) ?? 0 }
- on deposit(owner, amount) {
- let total = (balances.get(owner) ?? 0) + amount
+ on deposit(owner, cents) {
+ let total = (balances.get(owner) ?? 0) + cents
balances.set(owner, total)
return totalWith the fix, soma check accepts the program:
$ soma check right.cell
✓ All checks passed.