soma.cell

E0105: argument_type

E0105 argument_type — an argument whose type differs from the parameter's.

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

The rule

When a call passes a value whose type soma check can tell (a literal, or a local whose type it inferred) to a handler parameter declared with a different type, it reports E0105 at that argument, before the program runs. The fix is to pass a value of the declared type or to change the parameter's type. Here money is kept in Int cents, so the shipping fee is 499, not 4.99; an Int is accepted where a Float is declared, but not the reverse.

A program that triggers it

wrong.cell

cell Checkout {
    face {
        signal charge(order_id: String, cents: Int) -> Int
        signal add_shipping(order_id: String) -> Int
    }
    memory {
        totals: Map<String, Int> [persistent]
    }
    on charge(order_id: String, cents: Int) {
        let total = (totals.get(order_id) ?? 0) + cents
        totals.set(order_id, total)
        return total
    }
    on add_shipping(order_id: String) {
        return charge(order_id, 4.99)
    }
}

What soma check prints:

$ soma check wrong.cell
error: charge(): argument 2 is a Float literal but the handler declares it Int — fix the value or the parameter type
  --> wrong.cell:15:33
   |
15 |         return charge(order_id, 4.99)
   |                                 ^
  = code: E0105
✗ 1 error(s), 0 warning(s).

The fix field of soma check --json: fix the value or the parameter type

On line 15, return charge(order_id, 4.99) becomes return charge(order_id, 499).

wrong.cell → right.cell

--- wrong.cell
+++ right.cell
@@ -13,5 +13,5 @@
     }
     on add_shipping(order_id: String) {
-        return charge(order_id, 4.99)
+        return charge(order_id, 499)
     }
 }

With the fix, soma check accepts the program:

$ soma check right.cell
✓ All checks passed.