soma.cell

E1003: handler_return_type

E1003 handler_return_type — a return type on a handler — it goes on the face signal.

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

The rule

A handler (on name(...)) does not declare a return type; the return type of a signal belongs on its declaration in the face block (signal total(price: Int, qty: Int) -> Int). Keeping it in one place means the face is the single contract that callers and soma describe read. Remove -> Int from the on line and keep it on the face signal.

A program that triggers it

wrong.cell

cell Order {
    face {
        signal total(price: Int, qty: Int) -> Int
    }
    on total(price: Int, qty: Int) -> Int {
        return price * qty
    }
}

What soma check prints:

$ soma check wrong.cell
error: handlers do not declare return types — put '-> Int' on the signal declaration inside face { }, then write: on total(price: Int, qty: Int) { ... }
  --> wrong.cell:5:36
  |
5 |     on total(price: Int, qty: Int) -> Int {
  |                                    ^
  = code: E1003
✗ 1 error(s), 0 warning(s).

The fix field of soma check --json: put '-> Int' on the signal declaration inside face { }, then write: on total(price: Int, qty: Int) { ... }

On line 5, on total(price: Int, qty: Int) -> Int { becomes on total(price: Int, qty: Int) {.

wrong.cell → right.cell

--- wrong.cell
+++ right.cell
@@ -3,5 +3,5 @@
         signal total(price: Int, qty: Int) -> Int
     }
-    on total(price: Int, qty: Int) -> Int {
+    on total(price: Int, qty: Int) {
         return price * qty
     }

With the fix, soma check accepts the program:

$ soma check right.cell
✓ All checks passed.