-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/parser): Fix binary operator parsed as an instantiation expres…
…sion (#4992)
- Loading branch information
Showing
7 changed files
with
282 additions
and
1,166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_parser/tests/typescript-errors/instantiation-expr/case3/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
f<x> & g<y>; |
7 changes: 7 additions & 0 deletions
7
crates/swc_ecma_parser/tests/typescript-errors/instantiation-expr/case3/input.ts.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
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 | ||
,-[$DIR/tests/typescript-errors/instantiation-expr/case3/input.ts:1:1] | ||
1 | f<x> & g<y>; | ||
: ^ | ||
`---- |
3 changes: 3 additions & 0 deletions
3
crates/swc_ecma_parser/tests/typescript/instantiation-expr/bin-op/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
0 < 2 >> 1; | ||
a<b>>c<d>; | ||
a<b> + c; |
225 changes: 225 additions & 0 deletions
225
crates/swc_ecma_parser/tests/typescript/instantiation-expr/bin-op/input.ts.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,225 @@ | ||
{ | ||
"type": "Script", | ||
"span": { | ||
"start": 1, | ||
"end": 33, | ||
"ctxt": 0 | ||
}, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"span": { | ||
"start": 1, | ||
"end": 12, | ||
"ctxt": 0 | ||
}, | ||
"expression": { | ||
"type": "BinaryExpression", | ||
"span": { | ||
"start": 1, | ||
"end": 11, | ||
"ctxt": 0 | ||
}, | ||
"operator": "<", | ||
"left": { | ||
"type": "NumericLiteral", | ||
"span": { | ||
"start": 1, | ||
"end": 2, | ||
"ctxt": 0 | ||
}, | ||
"value": 0.0, | ||
"raw": "0" | ||
}, | ||
"right": { | ||
"type": "BinaryExpression", | ||
"span": { | ||
"start": 5, | ||
"end": 11, | ||
"ctxt": 0 | ||
}, | ||
"operator": ">>", | ||
"left": { | ||
"type": "NumericLiteral", | ||
"span": { | ||
"start": 5, | ||
"end": 6, | ||
"ctxt": 0 | ||
}, | ||
"value": 2.0, | ||
"raw": "2" | ||
}, | ||
"right": { | ||
"type": "NumericLiteral", | ||
"span": { | ||
"start": 10, | ||
"end": 11, | ||
"ctxt": 0 | ||
}, | ||
"value": 1.0, | ||
"raw": "1" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "ExpressionStatement", | ||
"span": { | ||
"start": 13, | ||
"end": 23, | ||
"ctxt": 0 | ||
}, | ||
"expression": { | ||
"type": "BinaryExpression", | ||
"span": { | ||
"start": 13, | ||
"end": 22, | ||
"ctxt": 0 | ||
}, | ||
"operator": "<", | ||
"left": { | ||
"type": "Identifier", | ||
"span": { | ||
"start": 13, | ||
"end": 14, | ||
"ctxt": 0 | ||
}, | ||
"value": "a", | ||
"optional": false | ||
}, | ||
"right": { | ||
"type": "BinaryExpression", | ||
"span": { | ||
"start": 15, | ||
"end": 22, | ||
"ctxt": 0 | ||
}, | ||
"operator": ">>", | ||
"left": { | ||
"type": "Identifier", | ||
"span": { | ||
"start": 15, | ||
"end": 16, | ||
"ctxt": 0 | ||
}, | ||
"value": "b", | ||
"optional": false | ||
}, | ||
"right": { | ||
"type": "TsInstantiation", | ||
"span": { | ||
"start": 18, | ||
"end": 22, | ||
"ctxt": 0 | ||
}, | ||
"expression": { | ||
"type": "Identifier", | ||
"span": { | ||
"start": 18, | ||
"end": 19, | ||
"ctxt": 0 | ||
}, | ||
"value": "c", | ||
"optional": false | ||
}, | ||
"typeArguments": { | ||
"type": "TsTypeParameterInstantiation", | ||
"span": { | ||
"start": 19, | ||
"end": 22, | ||
"ctxt": 0 | ||
}, | ||
"params": [ | ||
{ | ||
"type": "TsTypeReference", | ||
"span": { | ||
"start": 20, | ||
"end": 21, | ||
"ctxt": 0 | ||
}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"span": { | ||
"start": 20, | ||
"end": 21, | ||
"ctxt": 0 | ||
}, | ||
"value": "d", | ||
"optional": false | ||
}, | ||
"typeParams": null | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "ExpressionStatement", | ||
"span": { | ||
"start": 24, | ||
"end": 33, | ||
"ctxt": 0 | ||
}, | ||
"expression": { | ||
"type": "BinaryExpression", | ||
"span": { | ||
"start": 24, | ||
"end": 32, | ||
"ctxt": 0 | ||
}, | ||
"operator": ">", | ||
"left": { | ||
"type": "BinaryExpression", | ||
"span": { | ||
"start": 24, | ||
"end": 27, | ||
"ctxt": 0 | ||
}, | ||
"operator": "<", | ||
"left": { | ||
"type": "Identifier", | ||
"span": { | ||
"start": 24, | ||
"end": 25, | ||
"ctxt": 0 | ||
}, | ||
"value": "a", | ||
"optional": false | ||
}, | ||
"right": { | ||
"type": "Identifier", | ||
"span": { | ||
"start": 26, | ||
"end": 27, | ||
"ctxt": 0 | ||
}, | ||
"value": "b", | ||
"optional": false | ||
} | ||
}, | ||
"right": { | ||
"type": "UnaryExpression", | ||
"span": { | ||
"start": 29, | ||
"end": 32, | ||
"ctxt": 0 | ||
}, | ||
"operator": "+", | ||
"argument": { | ||
"type": "Identifier", | ||
"span": { | ||
"start": 31, | ||
"end": 32, | ||
"ctxt": 0 | ||
}, | ||
"value": "c", | ||
"optional": false | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"interpreter": null | ||
} |
10 changes: 0 additions & 10 deletions
10
crates/swc_ecma_parser/tests/typescript/instantiation-expr/more-exprs/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,4 @@ | ||
f<x>, g<y>; | ||
[f<x>]; | ||
f<x> ? g<y> : h<z>; | ||
f<x> ^ g<y>; | ||
f<x> & g<y>; | ||
f<x> | g<y>; | ||
f<x> && g<y>; | ||
f<x> || g<y>; | ||
{ f<x> } | ||
f<x> ?? g<y>; | ||
f<x> == g<y>; | ||
f<x> === g<y>; | ||
f<x> != g<y>; | ||
f<x> !== g<y>; |
Oops, something went wrong.
36ef3e4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark
es/full/minify/libraries/antd
1627693103
ns/iter (± 47557604
)1632070473
ns/iter (± 52580508
)1.00
es/full/minify/libraries/d3
436399415
ns/iter (± 4128628
)401797799
ns/iter (± 24230096
)1.09
es/full/minify/libraries/echarts
1652561294
ns/iter (± 27196647
)1616193879
ns/iter (± 47434892
)1.02
es/full/minify/libraries/jquery
100024966
ns/iter (± 3196061
)87624335
ns/iter (± 2447920
)1.14
es/full/minify/libraries/lodash
118319276
ns/iter (± 5933870
)114038467
ns/iter (± 4146657
)1.04
es/full/minify/libraries/moment
53323812
ns/iter (± 1231717
)51316965
ns/iter (± 955764
)1.04
es/full/minify/libraries/react
17890618
ns/iter (± 200667
)20979575
ns/iter (± 11866431
)0.85
es/full/minify/libraries/terser
611862160
ns/iter (± 11445617
)595492232
ns/iter (± 77139589
)1.03
es/full/minify/libraries/three
558827992
ns/iter (± 10348192
)539641817
ns/iter (± 25187582
)1.04
es/full/minify/libraries/typescript
3505422330
ns/iter (± 69670217
)3473601678
ns/iter (± 92341759
)1.01
es/full/minify/libraries/victory
719183432
ns/iter (± 7281857
)717503668
ns/iter (± 25697376
)1.00
es/full/minify/libraries/vue
144143393
ns/iter (± 3197838
)128903283
ns/iter (± 3812158
)1.12
es/full/codegen/es3
30564
ns/iter (± 600
)30193
ns/iter (± 2249
)1.01
es/full/codegen/es5
30666
ns/iter (± 785
)30743
ns/iter (± 746
)1.00
es/full/codegen/es2015
30679
ns/iter (± 919
)30353
ns/iter (± 1170
)1.01
es/full/codegen/es2016
30636
ns/iter (± 307
)30342
ns/iter (± 1185
)1.01
es/full/codegen/es2017
30652
ns/iter (± 228
)30304
ns/iter (± 1296
)1.01
es/full/codegen/es2018
30625
ns/iter (± 216
)30368
ns/iter (± 1231
)1.01
es/full/codegen/es2019
30617
ns/iter (± 224
)30270
ns/iter (± 927
)1.01
es/full/codegen/es2020
30715
ns/iter (± 645
)30303
ns/iter (± 578
)1.01
es/full/all/es3
184205945
ns/iter (± 5943436
)179033794
ns/iter (± 4777978
)1.03
es/full/all/es5
172605723
ns/iter (± 6080684
)167712278
ns/iter (± 6161213
)1.03
es/full/all/es2015
140347367
ns/iter (± 3413685
)136803363
ns/iter (± 7360874
)1.03
es/full/all/es2016
138677938
ns/iter (± 4194076
)135519381
ns/iter (± 4879826
)1.02
es/full/all/es2017
136906309
ns/iter (± 3505758
)135445036
ns/iter (± 4099418
)1.01
es/full/all/es2018
134900237
ns/iter (± 3782649
)134019492
ns/iter (± 4664806
)1.01
es/full/all/es2019
134189623
ns/iter (± 2407390
)133101642
ns/iter (± 5814132
)1.01
es/full/all/es2020
129311496
ns/iter (± 2512248
)128397507
ns/iter (± 3970068
)1.01
es/full/parser
688792
ns/iter (± 17077
)676644
ns/iter (± 31977
)1.02
es/full/base/fixer
29505
ns/iter (± 898
)28258
ns/iter (± 893
)1.04
es/full/base/resolver_and_hygiene
86064
ns/iter (± 988
)84994
ns/iter (± 6039
)1.01
serialization of ast node
204
ns/iter (± 1
)202
ns/iter (± 6
)1.01
serialization of serde
215
ns/iter (± 2
)210
ns/iter (± 7
)1.02
This comment was automatically generated by workflow using github-action-benchmark.