repl: ensure correct syntax error for await parsing
This updates the --experimental-repl-await
implementation to ensure that parse errors are classified into two groups:
- Parse errors which will be thrown by the v8 parser even without the await support
- Parse errors which are only known to the Acorn parser
For the first group, we ensure that we defer to the v8 parser error.
For the second group, we then decorate the Acorn parser error to look as close to the usual syntax errors as possible.
An example of case (2) is:
await Promise..resolve()
which with this PR will now throw:
Uncaught SyntaxError:
await Promise..resolve()
^
Unexpected token '.'
Compare this to an example of case (1):
Promise..resolve(await)
which throws:
Promise..resolve(await)
^
Uncaught SyntaxError: Unexpected token '.'
@nodejs/repl