rescript-lang / syntax

ReScript's syntax as a standalone repo.
MIT License
255 stars 38 forks source link

Fix issue where async as an id cannot be used with application and la… #708

Closed cristianoc closed 2 years ago

cristianoc commented 2 years ago

…belled arguments.

Fixes https://github.com/rescript-lang/syntax/issues/707

cristianoc commented 2 years ago

@IwanKaramazow would you check that there's nothing wrong with this fix in the heuristic for recognising es6 arrow functions? Is the early recognition of ~ just a perf shortcut, or does it have a deeper meaning?

IwanKaramazow commented 2 years ago

Is the early recognition of ~ just a perf shortcut, or does it have a deeper meaning?

Perf shortcut. There wasn't a case where (~ didn't mean an arrow expression.

Your fix is correct. Upon finding the async keyword it will now search for the closing ) and then look for an => to confirm if we're in a arrow expression.