soma.cell

E0060: task_native

E0060 task_native — [task] and [native] on one handler.

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

The rule

A handler cannot be both [task] and [native]: a native handler is compiled code that cannot call think(), and a task exists to wait on such calls. soma check refuses the combination. Drop one annotation; a numeric scoring function that never calls a model should keep only [native].

A program that triggers it

wrong.cell

cell Fraud {
    face {
        signal risk_score(amount_cents: Int, attempts: Int) -> Int
    }
    on risk_score(amount_cents: Int, attempts: Int) [task, native] {
        let score = 0
        if amount_cents > 100000 {
            score = score + 50
        }
        score = score + attempts * 10
        return score
    }
}

What soma check prints:

$ soma check wrong.cell
warning: [task] on `risk_score` makes no think() / vote() / await (nor calls a handler that does) — it runs as one atomic unit like a plain handler
  --> wrong.cell:5:5
  |
5 |     on risk_score(amount_cents: Int, attempts: Int) [task, nativ…
  |     ^
error: handler `risk_score` is both [task] and [native] — a native handler cannot call think(); drop one
  --> wrong.cell:5:5
  |
5 |     on risk_score(amount_cents: Int, attempts: Int) [task, nativ…
  |     ^
  = code: E0060
✗ 1 error(s), 1 warning(s).

The fix field of soma check --json: a native handler cannot call think(); drop one

On line 5, on risk_score(amount_cents: Int, attempts: Int) [task, native] { becomes on risk_score(amount_cents: Int, attempts: Int) [native] {.

wrong.cell → right.cell

--- wrong.cell
+++ right.cell
@@ -3,5 +3,5 @@
         signal risk_score(amount_cents: Int, attempts: Int) -> Int
     }
-    on risk_score(amount_cents: Int, attempts: Int) [task, native] {
+    on risk_score(amount_cents: Int, attempts: Int) [native] {
         let score = 0
         if amount_cents > 100000 {

With the fix, soma check accepts the program:

$ soma check right.cell
✓ All checks passed.