-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/codegen): Fix codegen of optional chaining expr with a comment (…
- Loading branch information
Showing
4 changed files
with
93 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"jsc": { | ||
"transform": { | ||
"decoratorVersion": "2022-03" | ||
}, | ||
"parser": { | ||
"syntax": "typescript", | ||
"tsx": false | ||
}, | ||
"target": "es2021", | ||
"loose": false, | ||
}, | ||
"module": { | ||
"type": "commonjs" | ||
}, | ||
"isModule": true, | ||
"minify": false | ||
} |
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,35 @@ | ||
const string1 = { errorCode: 'test' }; | ||
const string2 = 'test'; | ||
|
||
function evaluateWithoutComment() { | ||
return string1.errorCode === string2; | ||
} | ||
|
||
function evaluateWithComment() { | ||
return ( | ||
// This comment doesn't break return evaluation | ||
string1?.errorCode === string2 | ||
); | ||
} | ||
|
||
function evaluateWithCast() { | ||
return ( | ||
(string1 as { errorCode: string })?.errorCode === string2 | ||
); | ||
} | ||
|
||
function evaluateWithCastAndComment() { | ||
return ( | ||
// This comment seems to cause wrapping parantheses to get stripped, breaking the return evaluation | ||
(string1 as { errorCode: string })?.errorCode === string2 | ||
); | ||
} | ||
|
||
// Works, returns true | ||
console.log(`evaluateWithoutComment: ${evaluateWithoutComment()}`); | ||
// Works, returns true | ||
console.log(`evaluateWithComment: ${evaluateWithComment()}`); | ||
// Works, returns true | ||
console.log(`evaluateWithCast: ${evaluateWithCast()}`); | ||
// Breaks, returns undefined due to stripped parantheses | ||
console.log(`evaluateWithCastAndComment: ${evaluateWithCastAndComment()}`); |
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,27 @@ | ||
"use strict"; | ||
const string1 = { | ||
errorCode: 'test' | ||
}; | ||
const string2 = 'test'; | ||
function evaluateWithoutComment() { | ||
return string1.errorCode === string2; | ||
} | ||
function evaluateWithComment() { | ||
return(// This comment doesn't break return evaluation | ||
string1?.errorCode === string2); | ||
} | ||
function evaluateWithCast() { | ||
return string1?.errorCode === string2; | ||
} | ||
function evaluateWithCastAndComment() { | ||
return(// This comment seems to cause wrapping parantheses to get stripped, breaking the return evaluation | ||
string1?.errorCode === string2); | ||
} | ||
// Works, returns true | ||
console.log(`evaluateWithoutComment: ${evaluateWithoutComment()}`); | ||
// Works, returns true | ||
console.log(`evaluateWithComment: ${evaluateWithComment()}`); | ||
// Works, returns true | ||
console.log(`evaluateWithCast: ${evaluateWithCast()}`); | ||
// Breaks, returns undefined due to stripped parantheses | ||
console.log(`evaluateWithCastAndComment: ${evaluateWithCastAndComment()}`); |
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
f07bb48
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/bugs-1
292516
ns/iter (± 8947
)289009
ns/iter (± 4180
)1.01
es/full/minify/libraries/antd
1318265702
ns/iter (± 14442138
)1335949180
ns/iter (± 15128064
)0.99
es/full/minify/libraries/d3
277606393
ns/iter (± 4855569
)277101473
ns/iter (± 3180057
)1.00
es/full/minify/libraries/echarts
1061077829
ns/iter (± 5313346
)1066188492
ns/iter (± 9902355
)1.00
es/full/minify/libraries/jquery
84059914
ns/iter (± 269367
)84115193
ns/iter (± 240716
)1.00
es/full/minify/libraries/lodash
97395858
ns/iter (± 395724
)97537477
ns/iter (± 273068
)1.00
es/full/minify/libraries/moment
49899127
ns/iter (± 135451
)49861779
ns/iter (± 235227
)1.00
es/full/minify/libraries/react
17960080
ns/iter (± 70795
)17943263
ns/iter (± 45433
)1.00
es/full/minify/libraries/terser
218424976
ns/iter (± 1026938
)218275344
ns/iter (± 554907
)1.00
es/full/minify/libraries/three
387127503
ns/iter (± 2620053
)387824541
ns/iter (± 3848797
)1.00
es/full/minify/libraries/typescript
2655224390
ns/iter (± 8144988
)2657619646
ns/iter (± 22332243
)1.00
es/full/minify/libraries/victory
570967433
ns/iter (± 3738279
)578220388
ns/iter (± 7046643
)0.99
es/full/minify/libraries/vue
119676440
ns/iter (± 396872
)119381019
ns/iter (± 513512
)1.00
es/full/codegen/es3
33260
ns/iter (± 78
)33627
ns/iter (± 99
)0.99
es/full/codegen/es5
33288
ns/iter (± 72
)33754
ns/iter (± 117
)0.99
es/full/codegen/es2015
33195
ns/iter (± 94
)33755
ns/iter (± 53
)0.98
es/full/codegen/es2016
33244
ns/iter (± 79
)33716
ns/iter (± 80
)0.99
es/full/codegen/es2017
33237
ns/iter (± 66
)33677
ns/iter (± 137
)0.99
es/full/codegen/es2018
33238
ns/iter (± 58
)33658
ns/iter (± 44
)0.99
es/full/codegen/es2019
33274
ns/iter (± 102
)33716
ns/iter (± 58
)0.99
es/full/codegen/es2020
33260
ns/iter (± 58
)33711
ns/iter (± 84
)0.99
es/full/all/es3
163263887
ns/iter (± 1234734
)165814050
ns/iter (± 1028503
)0.98
es/full/all/es5
155869875
ns/iter (± 785701
)158607282
ns/iter (± 796684
)0.98
es/full/all/es2015
116157212
ns/iter (± 840627
)117209465
ns/iter (± 685074
)0.99
es/full/all/es2016
115178018
ns/iter (± 547436
)115938935
ns/iter (± 590553
)0.99
es/full/all/es2017
114443316
ns/iter (± 1049411
)115534417
ns/iter (± 1094279
)0.99
es/full/all/es2018
111936151
ns/iter (± 516555
)113320703
ns/iter (± 482366
)0.99
es/full/all/es2019
111330746
ns/iter (± 507583
)112380074
ns/iter (± 718673
)0.99
es/full/all/es2020
107229039
ns/iter (± 650779
)108376586
ns/iter (± 522639
)0.99
es/full/parser
487947
ns/iter (± 5621
)487834
ns/iter (± 6096
)1.00
es/full/base/fixer
17960
ns/iter (± 151
)17444
ns/iter (± 55
)1.03
es/full/base/resolver_and_hygiene
80166
ns/iter (± 93
)80416
ns/iter (± 155
)1.00
serialization of serde
298
ns/iter (± 1
)292
ns/iter (± 2
)1.02
css/minify/libraries/bootstrap
30096864
ns/iter (± 113336
)28554221
ns/iter (± 67509
)1.05
css/visitor/compare/clone
1679478
ns/iter (± 9700
)1644986
ns/iter (± 4910
)1.02
css/visitor/compare/visit_mut_span
1786433
ns/iter (± 7688
)1767657
ns/iter (± 5067
)1.01
css/visitor/compare/visit_mut_span_panic
1890277
ns/iter (± 9097
)1853611
ns/iter (± 6935
)1.02
css/visitor/compare/fold_span
2579837
ns/iter (± 9813
)2583829
ns/iter (± 7668
)1.00
css/visitor/compare/fold_span_panic
2772726
ns/iter (± 12140
)2752544
ns/iter (± 9888
)1.01
css/lexer/bootstrap_5_1_3
4407631
ns/iter (± 2979
)4463636
ns/iter (± 6334
)0.99
css/lexer/foundation_6_7_4
3723074
ns/iter (± 1914
)3747485
ns/iter (± 4827
)0.99
css/lexer/tailwind_3_1_1
707373
ns/iter (± 430
)713221
ns/iter (± 875
)0.99
css/parser/bootstrap_5_1_3
19519084
ns/iter (± 45458
)19174227
ns/iter (± 15143
)1.02
css/parser/foundation_6_7_4
15534832
ns/iter (± 51951
)15222130
ns/iter (± 20493
)1.02
css/parser/tailwind_3_1_1
3018001
ns/iter (± 2460
)2941572
ns/iter (± 5621
)1.03
es/codegen/colors
737456
ns/iter (± 402542
)726913
ns/iter (± 397223
)1.01
es/codegen/large
3183347
ns/iter (± 1702964
)2908098
ns/iter (± 1548888
)1.09
es/codegen/with-parser/colors
44740
ns/iter (± 200
)45872
ns/iter (± 251
)0.98
es/codegen/with-parser/large
484526
ns/iter (± 750
)486065
ns/iter (± 878
)1.00
es/minify/libraries/antd
1143525841
ns/iter (± 10724832
)1153605989
ns/iter (± 18773821
)0.99
es/minify/libraries/d3
239388362
ns/iter (± 733882
)238657398
ns/iter (± 1455534
)1.00
es/minify/libraries/echarts
903847670
ns/iter (± 9298348
)909062059
ns/iter (± 5753777
)0.99
es/minify/libraries/jquery
73016786
ns/iter (± 139473
)73043088
ns/iter (± 153766
)1.00
es/minify/libraries/lodash
86744032
ns/iter (± 334705
)86753667
ns/iter (± 200120
)1.00
es/minify/libraries/moment
43481592
ns/iter (± 37089
)43363911
ns/iter (± 144858
)1.00
es/minify/libraries/react
16002536
ns/iter (± 55721
)16020513
ns/iter (± 41503
)1.00
es/minify/libraries/terser
185892412
ns/iter (± 909617
)185402314
ns/iter (± 446827
)1.00
es/minify/libraries/three
320452353
ns/iter (± 1641837
)319963839
ns/iter (± 2249170
)1.00
es/minify/libraries/typescript
2249705147
ns/iter (± 8732012
)2245540931
ns/iter (± 9438747
)1.00
es/minify/libraries/victory
473957821
ns/iter (± 3109563
)475914460
ns/iter (± 2672778
)1.00
es/minify/libraries/vue
105569066
ns/iter (± 538857
)105867927
ns/iter (± 258162
)1.00
es/visitor/compare/clone
1940180
ns/iter (± 5581
)1966598
ns/iter (± 4014
)0.99
es/visitor/compare/visit_mut_span
2281329
ns/iter (± 2235
)2313909
ns/iter (± 4509
)0.99
es/visitor/compare/visit_mut_span_panic
2318659
ns/iter (± 3842
)2353777
ns/iter (± 4805
)0.99
es/visitor/compare/fold_span
3369344
ns/iter (± 7006
)3418358
ns/iter (± 7240
)0.99
es/visitor/compare/fold_span_panic
3513094
ns/iter (± 8841
)3540656
ns/iter (± 10296
)0.99
es/lexer/colors
13146
ns/iter (± 40
)13151
ns/iter (± 25
)1.00
es/lexer/angular
6023162
ns/iter (± 21460
)6126636
ns/iter (± 9998
)0.98
es/lexer/backbone
777852
ns/iter (± 2227
)791774
ns/iter (± 292
)0.98
es/lexer/jquery
4429536
ns/iter (± 6707
)4531191
ns/iter (± 4233
)0.98
es/lexer/jquery mobile
6771955
ns/iter (± 23862
)6937740
ns/iter (± 11068
)0.98
es/lexer/mootools
3512909
ns/iter (± 3145
)3580732
ns/iter (± 4113
)0.98
es/lexer/underscore
656614
ns/iter (± 697
)668222
ns/iter (± 358
)0.98
es/lexer/three
21232527
ns/iter (± 25959
)21556952
ns/iter (± 36039
)0.98
es/lexer/yui
3774634
ns/iter (± 2919
)3841424
ns/iter (± 3782
)0.98
es/parser/colors
27080
ns/iter (± 76
)27615
ns/iter (± 72
)0.98
es/parser/angular
13438968
ns/iter (± 53327
)13674175
ns/iter (± 55266
)0.98
es/parser/backbone
1972304
ns/iter (± 9622
)1996965
ns/iter (± 7900
)0.99
es/parser/jquery
10785445
ns/iter (± 50031
)10985595
ns/iter (± 35485
)0.98
es/parser/jquery mobile
16472557
ns/iter (± 66282
)16853459
ns/iter (± 101159
)0.98
es/parser/mootools
8280729
ns/iter (± 12496
)8453532
ns/iter (± 19746
)0.98
es/parser/underscore
1701016
ns/iter (± 10011
)1727303
ns/iter (± 7396
)0.98
es/parser/three
46803634
ns/iter (± 186067
)47445388
ns/iter (± 223408
)0.99
es/parser/yui
8220009
ns/iter (± 33711
)8322920
ns/iter (± 34851
)0.99
es/preset-env/usage/builtin_type
137285
ns/iter (± 32728
)135560
ns/iter (± 31843
)1.01
es/preset-env/usage/property
17011
ns/iter (± 187
)17269
ns/iter (± 53
)0.99
es/resolver/typescript
90583553
ns/iter (± 1150988
)90314118
ns/iter (± 1615966
)1.00
es/fixer/typescript
63429788
ns/iter (± 1466184
)63493640
ns/iter (± 536934
)1.00
es/hygiene/typescript
129046787
ns/iter (± 277540
)129485950
ns/iter (± 1043491
)1.00
es/resolver_with_hygiene/typescript
242665614
ns/iter (± 913117
)242965079
ns/iter (± 1402835
)1.00
es/visitor/base-perf/module_clone
59090
ns/iter (± 832
)59076
ns/iter (± 251
)1.00
es/visitor/base-perf/fold_empty
63652
ns/iter (± 184
)63365
ns/iter (± 311
)1.00
es/visitor/base-perf/fold_noop_impl_all
63689
ns/iter (± 315
)63374
ns/iter (± 331
)1.00
es/visitor/base-perf/fold_noop_impl_vec
63976
ns/iter (± 428
)63908
ns/iter (± 349
)1.00
es/visitor/base-perf/boxing_boxed_clone
56
ns/iter (± 0
)55
ns/iter (± 0
)1.02
es/visitor/base-perf/boxing_unboxed_clone
40
ns/iter (± 0
)39
ns/iter (± 0
)1.03
es/visitor/base-perf/boxing_boxed
109
ns/iter (± 0
)108
ns/iter (± 0
)1.01
es/visitor/base-perf/boxing_unboxed
78
ns/iter (± 0
)77
ns/iter (± 0
)1.01
es/visitor/base-perf/visit_empty
0
ns/iter (± 0
)0
ns/iter (± 0
)NaN
es/visitor/base-perf/visit_contains_this
2515
ns/iter (± 5
)2544
ns/iter (± 15
)0.99
es/base/parallel/resolver/typescript
4459789901
ns/iter (± 293980576
)4269831962
ns/iter (± 190598371
)1.04
es/base/parallel/hygiene/typescript
1455628912
ns/iter (± 14833791
)1450551781
ns/iter (± 6545858
)1.00
misc/visitors/time-complexity/time 5
121
ns/iter (± 7
)133
ns/iter (± 1
)0.91
misc/visitors/time-complexity/time 10
387
ns/iter (± 1
)370
ns/iter (± 10
)1.05
misc/visitors/time-complexity/time 15
735
ns/iter (± 3
)674
ns/iter (± 3
)1.09
misc/visitors/time-complexity/time 20
996
ns/iter (± 67
)1111
ns/iter (± 4
)0.90
misc/visitors/time-complexity/time 40
3596
ns/iter (± 39
)3563
ns/iter (± 9
)1.01
misc/visitors/time-complexity/time 60
7226
ns/iter (± 8
)7327
ns/iter (± 461
)0.99
This comment was automatically generated by workflow using github-action-benchmark.