Feature Request: Output Syntax Version on Failed Parse

I wasn’t sure where to drop this, whether in GitHub issues or here, but I figured here would probably fit better…

As a developer I would like to know when I accidentally use syntax unsupported in the current ecma version being parsed so that I can easily tell the difference between a true parsing error and the version’s syntax support.

In the case that ecma version is specified and a parsing failure occurs due to unsupported syntax which is defined in a later edition of ecmascript, additionally print out the culprit syntax and the version it was introduced.

Example cases:
All cases assume parsing as ES6.

  1. let a = async function () { ... }

Current error message: "Parsing error: Unexpected token function"

Proposed new message: "Parsing error: Unexpected token function. Culprit: keyword 'async' introduced in 'es2017+', parser settings 'es6'.

  1. /(?:\s*(?<!\\),\s*)+/gm

Current error message: "Parsing error: Invalid regular expression: /(?:\s*(?<!\\),\s*)+/: Invalid group"

Proposed new output: "Parsing error: Invalid regular expression: /(?:\s*(?<!\\),\s*)+/: Invalid group. Culprit: '(?<! )' regular expression negative lookbehind introduced in 'es2018+', parser settings: 'es6'"

The proposed outputs are more or less suggestions, as long as they are able to convey identifying info about the unsupported syntax, and the version in which it was introduced.

Note: I originally came across the use-case for this issue while using ESLint, here’s a reference to the original issue I opened there before realizing it used an external parser.