Skip to content

Commit

Permalink
feat(es/parser): Make error message helpful (#6535)
Browse files Browse the repository at this point in the history
**Related issue:**

 - Closes #6525.
  • Loading branch information
kdy1 committed Nov 29, 2022
1 parent 0167656 commit cb15721
Show file tree
Hide file tree
Showing 140 changed files with 259 additions and 582 deletions.
Expand Up @@ -7,8 +7,7 @@
//! 2 | }
//! `----
//!
//! x Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | function f(yield = yield) {
//! : ^^^^^
Expand Down
Expand Up @@ -7,8 +7,7 @@
//! 2 | }
//! `----
//!
//! x Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | function f(yield = yield) {
//! : ^^^^^
Expand Down
@@ -1,7 +1,6 @@
//// [FunctionDeclaration8_es6.ts]
//!
//! x Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,----
//! 1 | var v = { [yield]: foo }
//! : ^^^^^
Expand Down
@@ -1,7 +1,6 @@
//// [FunctionDeclaration8_es6.ts]
//!
//! x Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,----
//! 1 | var v = { [yield]: foo }
//! : ^^^^^
Expand Down
@@ -1,7 +1,6 @@
//// [YieldExpression1_es6.ts]
//!
//! x Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,----
//! 1 | yield;
//! : ^^^^^
Expand Down
@@ -1,7 +1,6 @@
//// [YieldExpression1_es6.ts]
//!
//! x Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,----
//! 1 | yield;
//! : ^^^^^
Expand Down
@@ -1,7 +1,6 @@
//// [YieldExpression8_es6.ts]
//!
//! x Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | yield(foo);
//! : ^^^^^
Expand Down
@@ -1,7 +1,6 @@
//// [YieldExpression8_es6.ts]
//!
//! x Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | yield(foo);
//! : ^^^^^
Expand Down
@@ -1,7 +1,6 @@
//// [YieldStarExpression1_es6.ts]
//!
//! x Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,----
//! 1 | yield * [];
//! : ^^^^^
Expand Down
@@ -1,7 +1,6 @@
//// [YieldStarExpression1_es6.ts]
//!
//! x Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,----
//! 1 | yield * [];
//! : ^^^^^
Expand Down
Expand Up @@ -10,8 +10,7 @@
//! 5 | I // This should be the identifier 'I'
//! `----
//!
//! x Unexpected token `interface`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string,
//! | regexp, ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 |
//! 2 | var interface: number, I: string;
Expand Down
Expand Up @@ -10,8 +10,7 @@
//! 5 | I // This should be the identifier 'I'
//! `----
//!
//! x Unexpected token `interface`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string,
//! | regexp, ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 |
//! 2 | var interface: number, I: string;
Expand Down
Expand Up @@ -10,8 +10,7 @@
//! 5 | {} // This should be a block body
//! `----
//!
//! x Unexpected token `interface`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string,
//! | regexp, ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 |
//! 2 | function f(interface: number, I: string) {
Expand Down
Expand Up @@ -10,8 +10,7 @@
//! 5 | {} // This should be a block body
//! `----
//!
//! x Unexpected token `interface`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string,
//! | regexp, ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 |
//! 2 | function f(interface: number, I: string) {
Expand Down
Expand Up @@ -10,8 +10,7 @@
//! 5 | interface // This should be the identifier 'interface'
//! `----
//!
//! x Unexpected token `interface`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string,
//! | regexp, ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[2:1]
//! 2 | var interface: number, I: string;
//! 3 |
Expand Down
Expand Up @@ -10,8 +10,7 @@
//! 5 | interface // This should be the identifier 'interface'
//! `----
//!
//! x Unexpected token `interface`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string,
//! | regexp, ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[2:1]
//! 2 | var interface: number, I: string;
//! 3 |
Expand Down
Expand Up @@ -12,8 +12,7 @@
//! 8 | var BOOLEAN2 = delete ;
//! `----
//!
//! x Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[2:1]
//! 2 | var ANY;
//! 3 |
Expand All @@ -37,8 +36,7 @@
//! 8 | var BOOLEAN2 = delete ;
//! `----
//!
//! x Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[5:1]
//! 5 | var BOOLEAN1 = ANY delete ; //expect error
//! 6 |
Expand Down
Expand Up @@ -12,8 +12,7 @@
//! 8 | var BOOLEAN2 = delete ;
//! `----
//!
//! x Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[2:1]
//! 2 | var ANY;
//! 3 |
Expand All @@ -37,8 +36,7 @@
//! 8 | var BOOLEAN2 = delete ;
//! `----
//!
//! x Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[5:1]
//! 5 | var BOOLEAN1 = ANY delete ; //expect error
//! 6 |
Expand Down
@@ -1,7 +1,6 @@
//// [generatorTypeCheck32.ts]
//!
//! x Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | var s: string;
//! 2 | var f: () => number = () => yield s;
Expand Down
@@ -1,7 +1,6 @@
//// [generatorTypeCheck32.ts]
//!
//! x Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | var s: string;
//! 2 | var f: () => number = () => yield s;
Expand Down
@@ -1,7 +1,6 @@
//// [generatorTypeCheck39.ts]
//!
//! x Unexpected token `@`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[2:1]
//! 2 | return y => { };
//! 3 | }
Expand Down
@@ -1,7 +1,6 @@
//// [generatorTypeCheck39.ts]
//!
//! x Unexpected token `@`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[2:1]
//! 2 | return y => { };
//! 3 | }
Expand Down
@@ -1,7 +1,6 @@
//// [generatorTypeCheck61.ts]
//!
//! x Unexpected token `@`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | function * g() {
//! 2 | @(yield 0)
Expand Down
@@ -1,7 +1,6 @@
//// [generatorTypeCheck61.ts]
//!
//! x Unexpected token `@`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | function * g() {
//! 2 | @(yield 0)
Expand Down
@@ -1,7 +1,6 @@
//// [logicalNotOperatorInvalidOperations.ts]
//!
//! x Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[8:1]
//! 8 | var BOOLEAN2 = !b + b;
//! 9 |
Expand Down
@@ -1,7 +1,6 @@
//// [logicalNotOperatorInvalidOperations.ts]
//!
//! x Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[8:1]
//! 8 | var BOOLEAN2 = !b + b;
//! 9 |
Expand Down
@@ -1,7 +1,6 @@
//// [parserComputedPropertyName37.ts]
//!
//! x Unexpected token `public`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | var v = {
//! 2 | [public]: 0
Expand Down
@@ -1,7 +1,6 @@
//// [parserComputedPropertyName37.ts]
//!
//! x Unexpected token `public`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | var v = {
//! 2 | [public]: 0
Expand Down
@@ -1,7 +1,6 @@
//// [parserInterfaceDeclaration3.ts]
//!
//! x Unexpected token `public`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | public interface I {
//! : ^^^^^^
Expand Down
@@ -1,7 +1,6 @@
//// [parserInterfaceDeclaration3.ts]
//!
//! x Unexpected token `public`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | public interface I {
//! : ^^^^^^
Expand Down
Expand Up @@ -10,8 +10,7 @@
//! 6 | private[key] = value;
//! `----
//!
//! x Unexpected token `private`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string,
//! | regexp, ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[3:1]
//! 3 | "set": function (key, value) {
//! 4 |
Expand Down
Expand Up @@ -10,8 +10,7 @@
//! 6 | private[key] = value;
//! `----
//!
//! x Unexpected token `private`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string,
//! | regexp, ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[3:1]
//! 3 | "set": function (key, value) {
//! 4 |
Expand Down
Expand Up @@ -11,8 +11,7 @@
//! 12 | <>eof // Error
//! `----
//!
//! x Unexpected token `>`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[9:1]
//! 9 |
//! 10 | <>hi</div> // Error
Expand Down
Expand Up @@ -11,8 +11,7 @@
//! 12 | <>eof // Error
//! `----
//!
//! x Unexpected token `>`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[9:1]
//! 9 |
//! 10 | <>hi</div> // Error
Expand Down
Expand Up @@ -12,8 +12,7 @@
//! 7 | var ANY1 = typeof ;
//! `----
//!
//! x Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | // Unary operator typeof
//! 2 |
Expand All @@ -25,8 +24,7 @@
//! 7 | var ANY1 = typeof ;
//! `----
//!
//! x Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[4:1]
//! 4 | var ANY = ANY typeof ; //expect error
//! 5 |
Expand Down
Expand Up @@ -12,8 +12,7 @@
//! 7 | var ANY1 = typeof ;
//! `----
//!
//! x Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | // Unary operator typeof
//! 2 |
Expand All @@ -25,8 +24,7 @@
//! 7 | var ANY1 = typeof ;
//! `----
//!
//! x Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[4:1]
//! 4 | var ANY = ANY typeof ; //expect error
//! 5 |
Expand Down
Expand Up @@ -12,8 +12,7 @@
//! 7 | var ANY1 = void ;
//! `----
//!
//! x Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | // Unary operator void
//! 2 |
Expand All @@ -25,8 +24,7 @@
//! 7 | var ANY1 = void ;
//! `----
//!
//! x Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[4:1]
//! 4 | var ANY = ANY void ; //expect error
//! 5 |
Expand Down

1 comment on commit cb15721

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: cb15721 Previous: 9752b43 Ratio
es/full/bugs-1 343776 ns/iter (± 23225) 357364 ns/iter (± 35796) 0.96
es/full/minify/libraries/antd 2148324252 ns/iter (± 48139045) 2131237530 ns/iter (± 72038343) 1.01
es/full/minify/libraries/d3 470452780 ns/iter (± 13182185) 480329648 ns/iter (± 15777311) 0.98
es/full/minify/libraries/echarts 1780933104 ns/iter (± 52006441) 1816439044 ns/iter (± 78383203) 0.98
es/full/minify/libraries/jquery 123795604 ns/iter (± 3649211) 124948647 ns/iter (± 6799524) 0.99
es/full/minify/libraries/lodash 141301219 ns/iter (± 6877106) 145997877 ns/iter (± 32065108) 0.97
es/full/minify/libraries/moment 67553329 ns/iter (± 3807315) 73168104 ns/iter (± 2262237) 0.92
es/full/minify/libraries/react 21983187 ns/iter (± 653902) 23579280 ns/iter (± 518914) 0.93
es/full/minify/libraries/terser 372109389 ns/iter (± 11189303) 416086071 ns/iter (± 41672935) 0.89
es/full/minify/libraries/three 639157732 ns/iter (± 73834351) 658232817 ns/iter (± 29911362) 0.97
es/full/minify/libraries/typescript 3822167868 ns/iter (± 108177072) 3920999765 ns/iter (± 85016022) 0.97
es/full/minify/libraries/victory 955538507 ns/iter (± 32511372) 942921236 ns/iter (± 18143935) 1.01
es/full/minify/libraries/vue 181163799 ns/iter (± 6184765) 183013789 ns/iter (± 9555227) 0.99
es/full/codegen/es3 35406 ns/iter (± 2952) 33808 ns/iter (± 1248) 1.05
es/full/codegen/es5 34262 ns/iter (± 2022) 33630 ns/iter (± 1120) 1.02
es/full/codegen/es2015 33933 ns/iter (± 1799) 34238 ns/iter (± 3398) 0.99
es/full/codegen/es2016 33291 ns/iter (± 1449) 33937 ns/iter (± 2419) 0.98
es/full/codegen/es2017 34179 ns/iter (± 1731) 34069 ns/iter (± 894) 1.00
es/full/codegen/es2018 33371 ns/iter (± 1205) 34065 ns/iter (± 663) 0.98
es/full/codegen/es2019 33580 ns/iter (± 2392) 34470 ns/iter (± 2486) 0.97
es/full/codegen/es2020 33693 ns/iter (± 1338) 34315 ns/iter (± 2747) 0.98
es/full/all/es3 203575014 ns/iter (± 11057333) 219182420 ns/iter (± 20462811) 0.93
es/full/all/es5 183029752 ns/iter (± 8793684) 177529055 ns/iter (± 8672744) 1.03
es/full/all/es2015 148654412 ns/iter (± 8755662) 141581974 ns/iter (± 6687565) 1.05
es/full/all/es2016 146463715 ns/iter (± 11617861) 141052236 ns/iter (± 6868129) 1.04
es/full/all/es2017 147396017 ns/iter (± 6200401) 140774098 ns/iter (± 7470869) 1.05
es/full/all/es2018 145171157 ns/iter (± 15225598) 139076792 ns/iter (± 6972836) 1.04
es/full/all/es2019 146642222 ns/iter (± 7795028) 146613024 ns/iter (± 5657803) 1.00
es/full/all/es2020 144751549 ns/iter (± 9725405) 138453334 ns/iter (± 7151806) 1.05
es/full/parser 729148 ns/iter (± 41764) 724678 ns/iter (± 34459) 1.01
es/full/base/fixer 26898 ns/iter (± 918) 26866 ns/iter (± 443) 1.00
es/full/base/resolver_and_hygiene 91839 ns/iter (± 3458) 94089 ns/iter (± 4151) 0.98
serialization of ast node 217 ns/iter (± 7) 219 ns/iter (± 8) 0.99
serialization of serde 234 ns/iter (± 10) 234 ns/iter (± 10) 1

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.