V3011 handler_clause_mismatch
A handler must provide exactly one clause per operation of its effect, with matching parameter counts (design §5.5).
An error from the effect phase. sakura explain V3011 prints this explanation offline.
A handler must provide exactly one clause per operation of its effect, with matching
parameter counts (design §5.5). Add the missing clause or remove the extra one.
Wrong:
effect Pair { fn left() -> Int; fn right() -> Int }
fn only_left() -> Handler<Pair> { handler Pair { fn left() { 1 } } }Fixed:
fn both() -> Handler<Pair> { handler Pair { fn left() { 1 }; fn right() { 2 } } }Wrong program
compiler/tests/ui/V3011_handler_clause_mismatch.sakura, which the compiler's ui suite runs through sakura check:
effect Pair {
fn left() -> Int
fn right() -> Int
}
fn only_left() -> Handler<Pair> {
handler Pair {
fn left() { 1 }
}
}sakura check --json reports this record (pretty-printed; $DIR is the fixture's directory):
{
"schema_version": "1.0",
"kind": "diagnostic",
"id": "d:1be4850aef641f24",
"code": "V3011",
"severity": "error",
"phase": "effect",
"message": "handler for `Pair` is missing a clause for `right`",
"snapshot": "sha256:$SNAPSHOT",
"symbol_id": "main::V3011_handler_clause_mismatch::only_left",
"spans": [
{
"uri": "file://$DIR/V3011_handler_clause_mismatch.sakura",
"content_hash": "sha256:97dd07d17fafd8305acbdc5c3f9d2e754f8f7d4664743a1acc04cafc1e52e2bd",
"start_byte": 126,
"end_byte": 164,
"role": "primary"
}
],
"related_ids": [],
"expected": null,
"actual": null,
"obligation": null,
"counterexample": null,
"explanation_uri": "sakura://explain/V3011",
"fixes": []
}Fixed program
compiler/tests/ui/V3011_handler_clause_mismatch.fixed.sakura, which sakura check accepts with no diagnostics:
effect Pair {
fn left() -> Int
fn right() -> Int
}
fn both() -> Handler<Pair> {
handler Pair {
fn left() { 1 }
fn right() { 2 }
}
}