tdewolff / parse

Go parsers for web formats
MIT License
413 stars 65 forks source link

js parser accepts a single backtick as valid js #98

Closed Adjective-Object closed 2 years ago

Adjective-Object commented 2 years ago

I would expect this to error, as it contains an unterminated string template literal.

ast, parseErr := js.Parse(parse.NewInputString("`"), js.Options{})

When run via node, it fails to parse

$ node
> eval('`')
Uncaught SyntaxError: Unexpected end of input

This was replicated against github.com/tdewolff/parse/v2 v2.5.29

If you can point me in the right direction, I can take a stab at fixing this!

tdewolff commented 2 years ago

Thanks Max, and thanks for offering to fix it! I've actually already gone ahead and fixed it, including a better error message for unterminated string.