erikd / language-javascript

Parser for JavaScript, in Haskell
BSD 3-Clause "New" or "Revised" License
160 stars 47 forks source link

`async` should be usable as an object key #131

Open cdepillabout opened 3 years ago

cdepillabout commented 3 years ago

There was a bug reported when trying to use language-javascript-0.7.1.0 in PureScript: https://github.com/purescript/purescript/pull/4199#issuecomment-962622105

It appears that async is completely treated as a keyword, and not allowed as an object key. So something like myObj.async doesn't parse. But apparently this is allowed in JS.

This was probably introduced in https://github.com/erikd/language-javascript/pull/113.

(I'm not super familiar with language-javascript, or even JS, but maybe @MonoidMusician, @garyb, or @JordanMartinez could follow-up on this if @erikd needs more information or I've reported this incorrectly.)

rhendric commented 3 years ago

I think myObj.async expressions parse correctly, as do { async: 0 } expressions and similar. I believe the issue that PureScript encountered was actually with a function (async) { ... } expression; I tested and encountered problems with that and with similar constructions using arrow syntax.