soma.cell

W0018: type_advisory

W0018 type_advisory — a type the inference could not settle; checked at run time.

A warning of soma check, the checker of the Soma programming language (soma explain W0018).

The rule

W0018 is a type finding of the inference pass that soma check reports as a warning and leaves to the run-time check; the message says it becomes an error in edition 2027. Here the handler returns a Map through a local while the face declares -> String, and soma run stops with "the face declares -> String but the handler returned Map". Make the value and the face agree, here by declaring -> Map (returning the Map literal directly, without the local, is already error E0040). The same code W0018 is also used for an untrusted value, a model's or an HTTP reply, that decides a transition() target or a URL without a check. It is also the edition-2026 warning for a type that checks nothing: a type name declared nowhere (q: Lots, read as Any) or a parameterised scalar (Int<lots>), which edition 2027 refuses as E0046.

A program that triggers it

wrong.cell

cell Orders {
    face {
        signal status(id: String) -> String
    }
    memory {
        statuses: Map<String, String> [persistent]
    }
    on status(id: String) {
        let current = statuses.get(id) ?? "unknown"
        let summary = map("id", id, "status", current)
        return summary
    }
}

What soma check prints:

$ soma check wrong.cell
warning: handler 'status' returns a Map (`summary`) but its face declares `-> String` — fix the value or the face (an error in edition 2027)
  --> wrong.cell:11:16
   |
11 |         return summary
   |                ^
✓ 1 warning(s), no errors.

The fix field of soma check --json: Review and address the reported warning.

On line 3, signal status(id: String) -> String becomes signal status(id: String) -> Map.

wrong.cell → right.cell

--- wrong.cell
+++ right.cell
@@ -1,5 +1,5 @@
 cell Orders {
     face {
-        signal status(id: String) -> String
+        signal status(id: String) -> Map
     }
     memory {

With the fix, soma check accepts the program:

$ soma check right.cell
✓ All checks passed.