You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed this potential issue in some frontend code that passes CSS classes to be rendered within a string template literals. Here's a reduced case to repro:
// This works
let opts = { class: 'hi' }
let ok = `${fn(opts)}`
This happens when the parameter class is included in the object passed to the function; this also occurs when the parameter name is function. I tried with a handful of other reserved JS keywords, and didn't find anything that reproduced, nor with other random parameter names.
Of course, the bad example does otherwise run:
let fn = opts => opts.class
console.log(`${fn({ class: 'hi' })}`)
Tested with Acorn 8.0.4 on Node.js 12.18.
The text was updated successfully, but these errors were encountered:
Sorry for the lag! And apologies in advance, I was apparently looking at the wrong bit of code when I reported this issue, it appears to be in tokenization. I created a reduced case repo, hopefully this helps! https://github.com/ryanblock/acorn-1001
Minor update: if instead of just spreading the results of the tokenizer on the AST, if I add the onToken param (with an array) to the parser options, I can get the token array just fine that was otherwise failing.
So the code just fails to tokenize correctly when not running the actual parser? That's unfortunately how JS tokenization works—it's sufficiently difficult that you need a parser to direct it in some corner cases. Making our tokenizer 100% independent is not a goal of this library.
I noticed this potential issue in some frontend code that passes CSS classes to be rendered within a string template literals. Here's a reduced case to repro:
Specifically, Acorn (
ecmaVersion: 'latest'
) throwsSyntaxError: Unterminated template (1:34)
.This happens when the parameter
class
is included in the object passed to the function; this also occurs when the parameter name isfunction
. I tried with a handful of other reserved JS keywords, and didn't find anything that reproduced, nor with other random parameter names.Of course, the bad example does otherwise run:
Tested with Acorn 8.0.4 on Node.js 12.18.
The text was updated successfully, but these errors were encountered: