language-javascript icon indicating copy to clipboard operation
language-javascript copied to clipboard

async keyword parsing

Open linearray opened this issue 4 years ago • 3 comments

I think the async keyword is not always parsed correctly. At some stage in my compilation/deployment pipeline this file is being parsed https://github.com/purescript-web/purescript-web-html/blob/d6960bcf86763a1b8c83641b7f0b46506eb3886e/src/Web/HTML/HTMLScriptElement.js and I encounter this error

  Unable to parse foreign module:
  
    .spago/web-html/v2.3.0/src/Web/HTML/HTMLScriptElement.js
  
    The module could not be parsed:
  
    AsyncToken {tokenSpan = TokenPn 1062 57 30, tokenLiteral = "async", tokenComment = []}

It does work with 0.7.0.0 though and I think the usage of async in the file is legal.

linearray avatar Jun 01 '20 20:06 linearray

According to section 11.6.2 of the ECMAScript 2021 Language Specification:

async is not reserved; it can be used as a variable name or statement label without restriction.

kurtmilam avatar Jun 01 '20 22:06 kurtmilam

@linearray Would you be able to post the two or three lines around the mis-parse?

erikd avatar Jun 04 '20 06:06 erikd

It fails right here where the parameter is called async : https://github.com/purescript-web/purescript-web-html/blob/d6960bcf86763a1b8c83641b7f0b46506eb3886e/src/Web/HTML/HTMLScriptElement.js#L57

linearray avatar Jun 04 '20 23:06 linearray