soma.cell

W0006: await_without_handler

W0006 await_without_handler — an await with no handler for its signal.

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

The rule

A face await name(...) says the cell expects to receive the signal name, so soma check warns with W0006 when the cell has no on name(...) handler for it. It is a warning rather than an error because the signal might be delivered over the bus from another process, but within one program an awaited signal with no handler does nothing in that cell. Add the handler with the same parameters (on withdraw(account: String, amount: Int) { … }), or remove the await from the face.

A program that triggers it

wrong.cell

cell Bank {
    interior {
        cell Teller {
            face { signal withdraw(account: String, amount: Int) }
            on withdraw(account: String, amount: Int) {
                return amount
            }
        }
        cell Ledger {
            face { await withdraw(account: String, amount: Int) }
            memory {
                debits: List<Int> [persistent]
            }
        }
    }
}

What soma check prints:

$ soma check wrong.cell
warning: cell 'Ledger' declares await 'withdraw' but has no handler for it (will it be delivered via bus?)
  --> wrong.cell:10:20
   |
10 |             face { await withdraw(account: String, amount: Int) }
   |                    ^
✓ 1 warning(s), no errors.

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

4 lines are added after line 13.

wrong.cell → right.cell

--- wrong.cell
+++ right.cell
@@ -12,4 +12,8 @@
                 debits: List<Int> [persistent]
             }
+            on withdraw(account: String, amount: Int) {
+                debits.push(amount)
+                return len(debits)
+            }
         }
     }

With the fix, soma check accepts the program:

$ soma check right.cell
✓ All checks passed.