Skip to content

Commit

Permalink
fix(es/compat): Handle PrivateName in logical_assignments (#7958)
Browse files Browse the repository at this point in the history
**Related issue:**

 - Closes #7956
  • Loading branch information
magic-akari authored Sep 16, 2023
1 parent e67bf05 commit 28318f0
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3 deletions.
10 changes: 10 additions & 0 deletions crates/swc/tests/fixture/issues-7xxx/7956/input/1/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"jsc": {
"parser": {
"syntax": "ecmascript"
}
},
"env": {
"targets": "chrome 74"
}
}
20 changes: 20 additions & 0 deletions crates/swc/tests/fixture/issues-7xxx/7956/input/1/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class A {
#a;
b() {
this.#a ||= 1;
}
c(x) {
x.#a ||= 1;
}
log() {
console.log(this.#a);
}
}

const x = new A();
x.b();
x.log();

const y = new A();
y.c(y);
y.log();
19 changes: 19 additions & 0 deletions crates/swc/tests/fixture/issues-7xxx/7956/output/1/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class A {
#a;
b() {
this.#a || (this.#a = 1);
}
c(x) {
var _x;
(_x = x).#a || (_x.#a = 1);
}
log() {
console.log(this.#a);
}
}
const x = new A();
x.b();
x.log();
const y = new A();
y.c(y);
y.log();
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ impl VisitMut for Operators {
};

let (left_prop, right_prop) = match m.prop.take() {
MemberProp::PrivateName(_) => {
unreachable!("private should be removed by class_properties")
}
MemberProp::Computed(c) => {
let (left, right) = self.memorize_prop(c);
(left.into(), right.into())
Expand Down

1 comment on commit 28318f0

@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: 28318f0 Previous: be5b02a Ratio
es/full/bugs-1 286021 ns/iter (± 7107) 283633 ns/iter (± 9139) 1.01
es/full/minify/libraries/antd 1319869114 ns/iter (± 8686045) 1331246836 ns/iter (± 12227104) 0.99
es/full/minify/libraries/d3 278049571 ns/iter (± 4275175) 277810953 ns/iter (± 7374611) 1.00
es/full/minify/libraries/echarts 1053486752 ns/iter (± 9926897) 1077040577 ns/iter (± 28674696) 0.98
es/full/minify/libraries/jquery 83910266 ns/iter (± 378398) 84534916 ns/iter (± 237290) 0.99
es/full/minify/libraries/lodash 96771875 ns/iter (± 303484) 97654222 ns/iter (± 356163) 0.99
es/full/minify/libraries/moment 49542812 ns/iter (± 315823) 50043838 ns/iter (± 182751) 0.99
es/full/minify/libraries/react 17955933 ns/iter (± 51575) 17956920 ns/iter (± 37733) 1.00
es/full/minify/libraries/terser 216513595 ns/iter (± 1064024) 220027862 ns/iter (± 1044971) 0.98
es/full/minify/libraries/three 382639578 ns/iter (± 2534498) 387416925 ns/iter (± 2002363) 0.99
es/full/minify/libraries/typescript 2630181213 ns/iter (± 18553945) 2671326786 ns/iter (± 13088365) 0.98
es/full/minify/libraries/victory 565509337 ns/iter (± 4421822) 570160546 ns/iter (± 4687994) 0.99
es/full/minify/libraries/vue 118552392 ns/iter (± 353522) 119321217 ns/iter (± 513251) 0.99
es/full/codegen/es3 34225 ns/iter (± 100) 34590 ns/iter (± 103) 0.99
es/full/codegen/es5 34144 ns/iter (± 137) 34484 ns/iter (± 542) 0.99
es/full/codegen/es2015 34148 ns/iter (± 58) 34577 ns/iter (± 71) 0.99
es/full/codegen/es2016 34167 ns/iter (± 61) 34620 ns/iter (± 72) 0.99
es/full/codegen/es2017 34119 ns/iter (± 230) 34672 ns/iter (± 92) 0.98
es/full/codegen/es2018 34162 ns/iter (± 33) 34645 ns/iter (± 73) 0.99
es/full/codegen/es2019 34113 ns/iter (± 33) 34618 ns/iter (± 91) 0.99
es/full/codegen/es2020 34103 ns/iter (± 114) 34582 ns/iter (± 155) 0.99
es/full/all/es3 167664747 ns/iter (± 980802) 168411868 ns/iter (± 892349) 1.00
es/full/all/es5 160297090 ns/iter (± 633525) 160439674 ns/iter (± 628238) 1.00
es/full/all/es2015 119734243 ns/iter (± 683138) 119895565 ns/iter (± 725272) 1.00
es/full/all/es2016 119292925 ns/iter (± 661461) 118481852 ns/iter (± 834638) 1.01
es/full/all/es2017 117862045 ns/iter (± 701316) 117358676 ns/iter (± 600219) 1.00
es/full/all/es2018 115624965 ns/iter (± 454523) 115270274 ns/iter (± 825018) 1.00
es/full/all/es2019 115195474 ns/iter (± 419208) 116015573 ns/iter (± 614362) 0.99
es/full/all/es2020 111193053 ns/iter (± 587967) 111595829 ns/iter (± 539298) 1.00
es/full/parser 490309 ns/iter (± 5251) 487466 ns/iter (± 5288) 1.01
es/full/base/fixer 17494 ns/iter (± 113) 18473 ns/iter (± 104) 0.95
es/full/base/resolver_and_hygiene 81628 ns/iter (± 156) 79986 ns/iter (± 123) 1.02
serialization of serde 294 ns/iter (± 1) 298 ns/iter (± 0) 0.99
css/minify/libraries/bootstrap 28957172 ns/iter (± 69911) 28419831 ns/iter (± 42498) 1.02
css/visitor/compare/clone 1680359 ns/iter (± 8459) 1673744 ns/iter (± 5757) 1.00
css/visitor/compare/visit_mut_span 1769539 ns/iter (± 8426) 1791608 ns/iter (± 7590) 0.99
css/visitor/compare/visit_mut_span_panic 1880543 ns/iter (± 4942) 1874853 ns/iter (± 7073) 1.00
css/visitor/compare/fold_span 2589611 ns/iter (± 7669) 2577126 ns/iter (± 8570) 1.00
css/visitor/compare/fold_span_panic 2750984 ns/iter (± 10437) 2761435 ns/iter (± 11331) 1.00
css/lexer/bootstrap_5_1_3 4474762 ns/iter (± 6625) 4415536 ns/iter (± 5023) 1.01
css/lexer/foundation_6_7_4 3756982 ns/iter (± 4938) 3785915 ns/iter (± 2315) 0.99
css/lexer/tailwind_3_1_1 714888 ns/iter (± 644) 710990 ns/iter (± 691) 1.01
css/parser/bootstrap_5_1_3 19739132 ns/iter (± 49112) 19545269 ns/iter (± 59421) 1.01
css/parser/foundation_6_7_4 15817944 ns/iter (± 25692) 15618911 ns/iter (± 43037) 1.01
css/parser/tailwind_3_1_1 3036016 ns/iter (± 11479) 2972186 ns/iter (± 2340) 1.02
es/codegen/colors 732550 ns/iter (± 397257) 727045 ns/iter (± 396594) 1.01
es/codegen/large 3128360 ns/iter (± 1664903) 3136711 ns/iter (± 1665470) 1.00
es/codegen/with-parser/colors 45597 ns/iter (± 158) 45348 ns/iter (± 647) 1.01
es/codegen/with-parser/large 486027 ns/iter (± 2806) 489030 ns/iter (± 1109) 0.99
es/minify/libraries/antd 1145554072 ns/iter (± 10523064) 1167927078 ns/iter (± 12012341) 0.98
es/minify/libraries/d3 241134816 ns/iter (± 877311) 239321326 ns/iter (± 887290) 1.01
es/minify/libraries/echarts 918431169 ns/iter (± 25627579) 912599713 ns/iter (± 7608211) 1.01
es/minify/libraries/jquery 73482482 ns/iter (± 167559) 73339713 ns/iter (± 155401) 1.00
es/minify/libraries/lodash 87386993 ns/iter (± 298553) 87153083 ns/iter (± 619687) 1.00
es/minify/libraries/moment 43495746 ns/iter (± 201911) 43831016 ns/iter (± 193018) 0.99
es/minify/libraries/react 16040339 ns/iter (± 92824) 16019942 ns/iter (± 38971) 1.00
es/minify/libraries/terser 186340681 ns/iter (± 1092058) 185540304 ns/iter (± 865352) 1.00
es/minify/libraries/three 322233868 ns/iter (± 1885189) 320921429 ns/iter (± 1930365) 1.00
es/minify/libraries/typescript 2245677571 ns/iter (± 12566848) 2280736973 ns/iter (± 17604711) 0.98
es/minify/libraries/victory 477557918 ns/iter (± 9157781) 478084090 ns/iter (± 4539240) 1.00
es/minify/libraries/vue 106517190 ns/iter (± 364260) 105705574 ns/iter (± 312801) 1.01
es/visitor/compare/clone 1928686 ns/iter (± 4540) 1931151 ns/iter (± 3337) 1.00
es/visitor/compare/visit_mut_span 2274278 ns/iter (± 5939) 2273356 ns/iter (± 3240) 1.00
es/visitor/compare/visit_mut_span_panic 2312875 ns/iter (± 5203) 2328179 ns/iter (± 10176) 0.99
es/visitor/compare/fold_span 3362057 ns/iter (± 9318) 3349903 ns/iter (± 10205) 1.00
es/visitor/compare/fold_span_panic 3514054 ns/iter (± 9696) 3522801 ns/iter (± 8330) 1.00
es/lexer/colors 13246 ns/iter (± 32) 13214 ns/iter (± 41) 1.00
es/lexer/angular 6150337 ns/iter (± 6273) 6075190 ns/iter (± 17878) 1.01
es/lexer/backbone 794103 ns/iter (± 922) 776315 ns/iter (± 1171) 1.02
es/lexer/jquery 4533984 ns/iter (± 71914) 4469822 ns/iter (± 13175) 1.01
es/lexer/jquery mobile 6908950 ns/iter (± 4360) 6819948 ns/iter (± 44427) 1.01
es/lexer/mootools 3581456 ns/iter (± 2586) 3540902 ns/iter (± 6414) 1.01
es/lexer/underscore 663870 ns/iter (± 303) 653667 ns/iter (± 1266) 1.02
es/lexer/three 21452733 ns/iter (± 38504) 21155983 ns/iter (± 21741) 1.01
es/lexer/yui 3830151 ns/iter (± 2011) 3785030 ns/iter (± 3770) 1.01
es/parser/colors 27366 ns/iter (± 322) 27557 ns/iter (± 53) 0.99
es/parser/angular 13634646 ns/iter (± 56500) 13713144 ns/iter (± 63831) 0.99
es/parser/backbone 1996852 ns/iter (± 8954) 2008145 ns/iter (± 11774) 0.99
es/parser/jquery 10900591 ns/iter (± 97865) 10967908 ns/iter (± 51597) 0.99
es/parser/jquery mobile 16806754 ns/iter (± 104680) 16735856 ns/iter (± 260807) 1.00
es/parser/mootools 8381820 ns/iter (± 18654) 8413955 ns/iter (± 18453) 1.00
es/parser/underscore 1711411 ns/iter (± 9737) 1731667 ns/iter (± 10198) 0.99
es/parser/three 47187074 ns/iter (± 562467) 47469165 ns/iter (± 493122) 0.99
es/parser/yui 8278287 ns/iter (± 31978) 8337048 ns/iter (± 29939) 0.99
es/preset-env/usage/builtin_type 136374 ns/iter (± 32537) 135180 ns/iter (± 32422) 1.01
es/preset-env/usage/property 16772 ns/iter (± 65) 16438 ns/iter (± 62) 1.02
es/resolver/typescript 91159952 ns/iter (± 913433) 94450018 ns/iter (± 1385853) 0.97
es/fixer/typescript 64272522 ns/iter (± 555241) 66911775 ns/iter (± 665578) 0.96
es/hygiene/typescript 132163209 ns/iter (± 732026) 135269608 ns/iter (± 714559) 0.98
es/resolver_with_hygiene/typescript 243136960 ns/iter (± 585076) 250243043 ns/iter (± 2717648) 0.97
es/visitor/base-perf/module_clone 59156 ns/iter (± 223) 59086 ns/iter (± 206) 1.00
es/visitor/base-perf/fold_empty 63173 ns/iter (± 216) 62610 ns/iter (± 281) 1.01
es/visitor/base-perf/fold_noop_impl_all 63148 ns/iter (± 143) 63014 ns/iter (± 172) 1.00
es/visitor/base-perf/fold_noop_impl_vec 63068 ns/iter (± 230) 62885 ns/iter (± 219) 1.00
es/visitor/base-perf/boxing_boxed_clone 56 ns/iter (± 0) 58 ns/iter (± 0) 0.97
es/visitor/base-perf/boxing_unboxed_clone 41 ns/iter (± 0) 40 ns/iter (± 0) 1.02
es/visitor/base-perf/boxing_boxed 109 ns/iter (± 0) 109 ns/iter (± 0) 1
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 2541 ns/iter (± 10) 2438 ns/iter (± 9) 1.04
es/base/parallel/resolver/typescript 3964127813 ns/iter (± 318105333) 4240050311 ns/iter (± 235031723) 0.93
es/base/parallel/hygiene/typescript 1444069318 ns/iter (± 16031581) 1477465434 ns/iter (± 16423000) 0.98
misc/visitors/time-complexity/time 5 150 ns/iter (± 1) 150 ns/iter (± 0) 1
misc/visitors/time-complexity/time 10 421 ns/iter (± 1) 452 ns/iter (± 0) 0.93
misc/visitors/time-complexity/time 15 789 ns/iter (± 7) 796 ns/iter (± 0) 0.99
misc/visitors/time-complexity/time 20 1385 ns/iter (± 75) 1283 ns/iter (± 2) 1.08
misc/visitors/time-complexity/time 40 4332 ns/iter (± 11) 4356 ns/iter (± 7) 0.99
misc/visitors/time-complexity/time 60 10591 ns/iter (± 10) 10601 ns/iter (± 18) 1.00
es/full-target/es2016 232346 ns/iter (± 729) 232949 ns/iter (± 930) 1.00
es/full-target/es2017 221290 ns/iter (± 834) 221136 ns/iter (± 577) 1.00
es/full-target/es2018 208667 ns/iter (± 671) 208744 ns/iter (± 534) 1.00
es2020_nullish_coalescing 71141 ns/iter (± 490) 70082 ns/iter (± 444) 1.02
es2020_optional_chaining 78736 ns/iter (± 246) 77606 ns/iter (± 186) 1.01
es2022_class_properties 115525 ns/iter (± 302) 113636 ns/iter (± 259) 1.02
es2018_object_rest_spread 75561 ns/iter (± 188) 73996 ns/iter (± 298) 1.02
es2019_optional_catch_binding 64356 ns/iter (± 249) 62507 ns/iter (± 208) 1.03
es2017_async_to_generator 63700 ns/iter (± 170) 62630 ns/iter (± 233) 1.02
es2016_exponentiation 68338 ns/iter (± 267) 66755 ns/iter (± 232) 1.02
es2015_arrow 72341 ns/iter (± 295) 70576 ns/iter (± 170) 1.03
es2015_block_scoped_fn 68797 ns/iter (± 334) 67232 ns/iter (± 251) 1.02
es2015_block_scoping 123164 ns/iter (± 439) 122858 ns/iter (± 453) 1.00

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

Please sign in to comment.