Open ratmice opened 4 years ago
Unlike OCaml, Successor ML can nest guards, so you can write a correct version of Scherer et al.'s example:
| (Const n if is_neutral n, a) | (a, Const n if is_neutral n) => a
Of course, that doesn't make the warning they discuss irrelevant.
I didn't see an issue for this, I hope it isn't retreading anything,
the summary of proposed changes contains both disjunctive patterns, and pattern guards. In the (very succinct!) paper ambiguous pattern variables by Scherer et al, from the ML workshop 2016, this combination lead to patterns whose interpretation probably won't match a users naive expectation.
In the case of Ocaml this lead to a new warning, I have yet to look at the proposed semantics for Successor ML to figure out if it is impacted, or if there is an
terrible solution such as evaluating the guard twicewhich would work. As such, not really proposing anything, but thought it should be discussed.Edit: Initially I had the thought that such cases could be resolved by expanding the pattern guard to evaluate to is_neutral n orelse is_neutral n' after alpha conversion, but this direction seems real misguided so I struck that out.