soma.cell

E0048: unknown_handler

E0048 unknown_handler — a handler name nothing defines.

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

The rule

A qualified call Cell.handler(…) names a handler that the target cell does not define. Soma resolves calls into other cells at check time, because the runtime looks the handler up by name and would fail on the call. Call a handler the cell actually defines, or add the missing on handler to that cell.

A program that triggers it

wrong.cell

cell Ledger {
    memory {
        balances: Map<String, Int> [persistent]
    }
    on credit(account: String, cents: Int) {
        let next = (balances.get(account) ?? 0) + cents
        balances.set(account, next)
        return next
    }
}

cell Refunds {
    on refund(account: String, cents: Int) {
        require cents > 0 else InvalidAmount
        return Ledger.deposit(account, cents)
    }
}

What soma check prints:

$ soma check wrong.cell
error: cell 'Ledger' has no handler 'deposit'
  --> wrong.cell:15:16
   |
15 |         return Ledger.deposit(account, cents)
   |                ^
  = code: E0048
✗ 1 error(s), 0 warning(s).

The fix field of soma check --json: cell 'Ledger' has no handler 'deposit'

On line 15, return Ledger.deposit(account, cents) becomes return Ledger.credit(account, cents).

wrong.cell → right.cell

--- wrong.cell
+++ right.cell
@@ -13,5 +13,5 @@
     on refund(account: String, cents: Int) {
         require cents > 0 else InvalidAmount
-        return Ledger.deposit(account, cents)
+        return Ledger.credit(account, cents)
     }
 }

With the fix, soma check accepts the program:

$ soma check right.cell
✓ All checks passed.