RESS icon indicating copy to clipboard operation
RESS copied to clipboard

Disambiguate optional chaining operator from ternary operator

Open Fee0 opened this issue 10 months ago • 6 comments

not sure if skipping ahead and then skipping back is the best solution here

Fee0 avatar Apr 05 '24 08:04 Fee0

I think skipping ahead and then skipping back is really the only way in this case. Thinking through this particular part of the grammar there is one more thing we need to account for: whitespace.

The following are valid optional chains

let a = null

a?. b
a?. ()
a?. [3]

so I think just checking for the next char isn't going to be enough. Instead, it might make sense to test for that period being part of a Number. To do what, we should be able to use something like

if self.stream.at_decimal() {
  // not optional chain
} else {
  // optional chain
}

Sorry that I didn't see this issue when bringing up the ident_start option

FreeMasen avatar Apr 05 '24 15:04 FreeMasen

You are right. Sorry, I forgot that there can be white spaces in between. I makes much more sense with checking for a decimal number with a dot in front.

Fee0 avatar Apr 08 '24 13:04 Fee0

One last nit: Can you squash the fmt commit into Added tests for es2020 operators? then I can merge it and publish the new version

FreeMasen avatar Apr 08 '24 17:04 FreeMasen

You want to do a new version despite missing support for the new operators for the non-spanned module? I will have a look at this as well. Just not sure when I got some time.

Fee0 avatar Apr 09 '24 08:04 Fee0

The resast wouldn't get published, just a new alpha version of ress that can be consumed by ressa to generate the resast changes you are working on.

sorry, the landscape here is a little confusing with all the different repositories. I have been thinking of trying to collapse them all into a single crate with feature gates but that seems like it would be particularly challenging.

FreeMasen avatar Apr 09 '24 22:04 FreeMasen

ahh makes sense. Yes, its a little confusing, also with a lot of different branches. On the other side I do like the modularity :)

Squashed the commits

Fee0 avatar Apr 10 '24 12:04 Fee0