bynk.expect.outside_case
Error expect was used outside a case body.
expect is a test claim, checked when a case runs. Production code has no test runner to report a failure to, so an expect in a function, a handler or anywhere else outside a case body is refused. To check a condition in running code, return a Bool or a Result; to check it in a test, move the expect into a case. A requires or ensures contract is the always-on form.
Example
fn positive(n: Int) -> Bool { expect n > 0 // ✗ not in a case n > 0}
// tests/rules.test.bynkexpect positive(1) // ✓ in a caseIn the Book
See also
- The grammar rule it governs:
expect_expr. - Every code in its category, Expectations, on the diagnostic index.
bynk explain bynk.expect.outside_caseshows the same from the installed toolchain, without a network.