rescript-compiler
rescript-compiler copied to clipboard
add bitor (|) unified operator
I used the existing Token.Bar, it looks like there's a conflict with the | used in pattern matching, so I'm looking into it.
Ok, this is actually ambiguous.
switch n {
| n => n | 1
// ^ Is this an or-pattern or binary expression?
This is tricky because we don't force a delimiter at the end of the pattern (like , in Rust)
We can put it in a new region to avoid ambiguity
switch n {
| n => { n | 1 }
// or....
| n => ( n | 1 )
The problem is that our formatter actively tries to wipe it out.
Maybe reviving local open syntax would help to deal with this kind of ambiguity