-
-
Notifications
You must be signed in to change notification settings - Fork 32
Description
If you write a case statement such that the branches leave the context inconsistent such as in the following:
def Test = chan ret: ? {
let b: Bool = .true!
b.case {
.true! => {let c: choice {.a => !} = case {.a => !}}
.false! => {}
}
// let ! = c.a
ret <> !
}
then the error is
× Cannot end this process before handling `c`.
╭─[8:12]
7 │ //let ! = c.a
8 │ ret <> !
· ─
9 │ }
╰────
which makes sense from the desugared .true! branch.
But if you try to handle that c by uncommenting the line above let ! = c.a
then you get a new error:
× Variable `c` does not exist.
╭─[7:13]
6 │ }
7 │ let ! = c.a
· ─
8 │ ret <> !
╰────
which makes sense from the .false! branch.
However, since neither error mentions the real source of the issue, namely that the linear variables from the match are inconsistent, the errors are simply confusing.
Similar issues will occur if the types of variables in the context don't match, but their names do, or any other situation where the context is inconsistent, from the different branches.
A solution would be to detect when the context is inconsistent as a result of the branch. I assume the errors currently work this way because the information about the root cause being from the inconsistent pass branches ({}) doesn't exist in the actual desugaring to process syntax.