Skip to content

Commit f7072db

Browse files
authoredNov 17, 2022
fix(es/compat): Fix consecutive optional call (#6461)
1 parent c333b0d commit f7072db

15 files changed

+90
-59
lines changed
 

‎crates/swc/tests/tsc-references/controlFlowOptionalChain.1.normal.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// assignments in shortcutting chain
33
import _instanceof from "@swc/helpers/src/_instanceof.mjs";
44
import _type_of from "@swc/helpers/src/_type_of.mjs";
5-
var _o4_x, _o4_x1, _o5_x, _ref, _o5_x1, _o5_x2, _o5_x3, _ref1, _arr_i;
5+
var _o4_x, _o4_x1, _o5_x_y_z, _o5_x, _o5_x1, _o5_x2, _o5_x_y_z1, _o5_x3, _arr_i;
66
var a;
77
o === null || o === void 0 ? void 0 : o[a = 1];
88
a.toString();
@@ -68,28 +68,28 @@ if ((_o4_x = o4.x) === null || _o4_x === void 0 ? void 0 : _o4_x.y) {
6868
o4.x;
6969
(_o4_x1 = o4.x) === null || _o4_x1 === void 0 ? void 0 : _o4_x1.y;
7070
o4.x.y;
71-
if ((_ref = (_o5_x = o5.x) === null || _o5_x === void 0 ? void 0 : _o5_x.y.z) === null || _ref === void 0 ? void 0 : _ref.w) {
72-
var _o5_x_y_z, _o5_x4, _o5_x5, _ref2;
71+
if ((_o5_x_y_z = (_o5_x = o5.x) === null || _o5_x === void 0 ? void 0 : _o5_x.y.z) === null || _o5_x_y_z === void 0 ? void 0 : _o5_x_y_z.w) {
72+
var _o5_x_y_z2, _o5_x4, _o5_x_y_z3, _o5_x5;
7373
o5.x;
7474
o5.x.y;
7575
o5.x.y.z;
7676
o5.x.y.z.w; // true
77-
(_o5_x_y_z = o5.x.y.z) === null || _o5_x_y_z === void 0 ? void 0 : _o5_x_y_z.w; // true
77+
(_o5_x_y_z2 = o5.x.y.z) === null || _o5_x_y_z2 === void 0 ? void 0 : _o5_x_y_z2.w; // true
7878
(_o5_x4 = o5.x) === null || _o5_x4 === void 0 ? void 0 : _o5_x4.y.z.w; // true
79-
(_ref2 = (_o5_x5 = o5.x) === null || _o5_x5 === void 0 ? void 0 : _o5_x5.y.z) === null || _ref2 === void 0 ? void 0 : _ref2.w; // true
79+
(_o5_x_y_z3 = (_o5_x5 = o5.x) === null || _o5_x5 === void 0 ? void 0 : _o5_x5.y.z) === null || _o5_x_y_z3 === void 0 ? void 0 : _o5_x_y_z3.w; // true
8080
} else {
81-
var _o5_x6, _o5_x7, _o5_x8, _ref3;
81+
var _o5_x6, _o5_x7, _o5_x_y_z4, _o5_x8;
8282
o5.x;
8383
(_o5_x6 = o5.x) === null || _o5_x6 === void 0 ? void 0 : _o5_x6.y;
8484
(_o5_x7 = o5.x) === null || _o5_x7 === void 0 ? void 0 : _o5_x7.y.z;
85-
(_ref3 = (_o5_x8 = o5.x) === null || _o5_x8 === void 0 ? void 0 : _o5_x8.y.z) === null || _ref3 === void 0 ? void 0 : _ref3.w;
85+
(_o5_x_y_z4 = (_o5_x8 = o5.x) === null || _o5_x8 === void 0 ? void 0 : _o5_x8.y.z) === null || _o5_x_y_z4 === void 0 ? void 0 : _o5_x_y_z4.w;
8686
o5.x.y;
8787
o5.x.y.z.w;
8888
}
8989
o5.x;
9090
(_o5_x1 = o5.x) === null || _o5_x1 === void 0 ? void 0 : _o5_x1.y;
9191
(_o5_x2 = o5.x) === null || _o5_x2 === void 0 ? void 0 : _o5_x2.y.z;
92-
(_ref1 = (_o5_x3 = o5.x) === null || _o5_x3 === void 0 ? void 0 : _o5_x3.y.z) === null || _ref1 === void 0 ? void 0 : _ref1.w;
92+
(_o5_x_y_z1 = (_o5_x3 = o5.x) === null || _o5_x3 === void 0 ? void 0 : _o5_x3.y.z) === null || _o5_x_y_z1 === void 0 ? void 0 : _o5_x_y_z1.w;
9393
o5.x.y;
9494
o5.x.y.z.w;
9595
if (o6 === null || o6 === void 0 ? void 0 : o6.f()) {

‎crates/swc/tests/tsc-references/controlFlowOptionalChain.2.minified.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
//// [deleteChain.ts]
2-
var _o3_b, _o3_b1, _o4_b, _ref, _o4_b1, _ref1, _o4_b2, _ref2, _o5_b, _ref3, _o5_b1, _ref4, _o6_b, _ref5, _o6_b1, _ref6;
2+
var _o3_b, _o3_b1, _o4_b_c_d, _o4_b, _o4_b_c_d1, _o4_b1, _o4_b_c_d2, _o4_b2, _o5_b_c_d, _o5_b, _o5_b_c_d1, _o5_b1, _o6_b_c_d, _o6_b, _o6_b_c_d1, _o6_b1;
33
o1 === null || o1 === void 0 ? void 0 : delete o1.b;
44
delete (o1 === null || o1 === void 0 ? void 0 : o1.b);
55
o2 === null || o2 === void 0 ? void 0 : delete o2.b.c;
66
o2 === null || o2 === void 0 ? void 0 : delete o2.b.c;
77
(_o3_b = o3.b) === null || _o3_b === void 0 ? void 0 : delete _o3_b.c;
88
delete ((_o3_b1 = o3.b) === null || _o3_b1 === void 0 ? void 0 : _o3_b1.c);
9-
(_ref = (_o4_b = o4.b) === null || _o4_b === void 0 ? void 0 : _o4_b.c.d) === null || _ref === void 0 ? void 0 : delete _ref.e;
10-
(_ref1 = (_o4_b1 = o4.b) === null || _o4_b1 === void 0 ? void 0 : _o4_b1.c.d) === null || _ref1 === void 0 ? void 0 : delete _ref1.e;
11-
delete ((_ref2 = (_o4_b2 = o4.b) === null || _o4_b2 === void 0 ? void 0 : _o4_b2.c.d) === null || _ref2 === void 0 ? void 0 : _ref2.e);
12-
(_ref3 = (_o5_b = o5.b) === null || _o5_b === void 0 ? void 0 : _o5_b.call(o5).c.d) === null || _ref3 === void 0 ? void 0 : delete _ref3.e;
13-
delete ((_ref4 = (_o5_b1 = o5.b) === null || _o5_b1 === void 0 ? void 0 : _o5_b1.call(o5).c.d) === null || _ref4 === void 0 ? void 0 : _ref4.e);
14-
(_ref5 = (_o6_b = o6.b) === null || _o6_b === void 0 ? void 0 : _o6_b["c"].d) === null || _ref5 === void 0 ? void 0 : delete _ref5["e"];
15-
delete ((_ref6 = (_o6_b1 = o6.b) === null || _o6_b1 === void 0 ? void 0 : _o6_b1["c"].d) === null || _ref6 === void 0 ? void 0 : _ref6["e"]);
9+
(_o4_b_c_d = (_o4_b = o4.b) === null || _o4_b === void 0 ? void 0 : _o4_b.c.d) === null || _o4_b_c_d === void 0 ? void 0 : delete _o4_b_c_d.e;
10+
(_o4_b_c_d1 = (_o4_b1 = o4.b) === null || _o4_b1 === void 0 ? void 0 : _o4_b1.c.d) === null || _o4_b_c_d1 === void 0 ? void 0 : delete _o4_b_c_d1.e;
11+
delete ((_o4_b_c_d2 = (_o4_b2 = o4.b) === null || _o4_b2 === void 0 ? void 0 : _o4_b2.c.d) === null || _o4_b_c_d2 === void 0 ? void 0 : _o4_b_c_d2.e);
12+
(_o5_b_c_d = (_o5_b = o5.b) === null || _o5_b === void 0 ? void 0 : _o5_b.call(o5).c.d) === null || _o5_b_c_d === void 0 ? void 0 : delete _o5_b_c_d.e;
13+
delete ((_o5_b_c_d1 = (_o5_b1 = o5.b) === null || _o5_b1 === void 0 ? void 0 : _o5_b1.call(o5).c.d) === null || _o5_b_c_d1 === void 0 ? void 0 : _o5_b_c_d1.e);
14+
(_o6_b_c_d = (_o6_b = o6.b) === null || _o6_b === void 0 ? void 0 : _o6_b["c"].d) === null || _o6_b_c_d === void 0 ? void 0 : delete _o6_b_c_d["e"];
15+
delete ((_o6_b_c_d1 = (_o6_b1 = o6.b) === null || _o6_b1 === void 0 ? void 0 : _o6_b1["c"].d) === null || _o6_b_c_d1 === void 0 ? void 0 : _o6_b_c_d1["e"]);

‎crates/swc/tests/tsc-references/deleteChain.2.minified.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/swc/tests/tsc-references/elementAccessChain.1.normal.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
//// [elementAccessChain.ts]
2-
var _o3_b, _o3_b1, _o4_b, _ref, _o4_b1, _ref1, _o5_b, _ref2, _o5_b1, _ref3, _o5_b2, _ref4, _o5_b3, _ref5, _o6;
2+
var _o3_b, _o3_b1, _o4_b_c_d, _o4_b, _o4_b_c_d1, _o4_b1, _o5_b_c_d, _o5_b, _o5_b_c_d1, _o5_b1, _o5_b_c_d2, _o5_b2, _o5_b_c_d3, _o5_b3, _o6;
33
o1 === null || o1 === void 0 ? void 0 : o1["b"];
44
o2 === null || o2 === void 0 ? void 0 : o2["b"].c;
55
o2 === null || o2 === void 0 ? void 0 : o2.b["c"];
66
(_o3_b = o3["b"]) === null || _o3_b === void 0 ? void 0 : _o3_b.c;
77
(_o3_b1 = o3.b) === null || _o3_b1 === void 0 ? void 0 : _o3_b1["c"];
8-
(_ref = (_o4_b = o4.b) === null || _o4_b === void 0 ? void 0 : _o4_b["c"].d) === null || _ref === void 0 ? void 0 : _ref.e;
9-
(_ref1 = (_o4_b1 = o4.b) === null || _o4_b1 === void 0 ? void 0 : _o4_b1["c"].d) === null || _ref1 === void 0 ? void 0 : _ref1["e"];
10-
(_ref2 = (_o5_b = o5.b) === null || _o5_b === void 0 ? void 0 : _o5_b.call(o5)["c"].d) === null || _ref2 === void 0 ? void 0 : _ref2.e;
11-
(_ref3 = (_o5_b1 = o5.b) === null || _o5_b1 === void 0 ? void 0 : _o5_b1.call(o5)["c"].d) === null || _ref3 === void 0 ? void 0 : _ref3["e"];
12-
(_ref4 = (_o5_b2 = o5["b"]) === null || _o5_b2 === void 0 ? void 0 : _o5_b2.call(o5)["c"].d) === null || _ref4 === void 0 ? void 0 : _ref4.e;
13-
(_ref5 = (_o5_b3 = o5["b"]) === null || _o5_b3 === void 0 ? void 0 : _o5_b3.call(o5)["c"].d) === null || _ref5 === void 0 ? void 0 : _ref5["e"];
8+
(_o4_b_c_d = (_o4_b = o4.b) === null || _o4_b === void 0 ? void 0 : _o4_b["c"].d) === null || _o4_b_c_d === void 0 ? void 0 : _o4_b_c_d.e;
9+
(_o4_b_c_d1 = (_o4_b1 = o4.b) === null || _o4_b1 === void 0 ? void 0 : _o4_b1["c"].d) === null || _o4_b_c_d1 === void 0 ? void 0 : _o4_b_c_d1["e"];
10+
(_o5_b_c_d = (_o5_b = o5.b) === null || _o5_b === void 0 ? void 0 : _o5_b.call(o5)["c"].d) === null || _o5_b_c_d === void 0 ? void 0 : _o5_b_c_d.e;
11+
(_o5_b_c_d1 = (_o5_b1 = o5.b) === null || _o5_b1 === void 0 ? void 0 : _o5_b1.call(o5)["c"].d) === null || _o5_b_c_d1 === void 0 ? void 0 : _o5_b_c_d1["e"];
12+
(_o5_b_c_d2 = (_o5_b2 = o5["b"]) === null || _o5_b2 === void 0 ? void 0 : _o5_b2.call(o5)["c"].d) === null || _o5_b_c_d2 === void 0 ? void 0 : _o5_b_c_d2.e;
13+
(_o5_b_c_d3 = (_o5_b3 = o5["b"]) === null || _o5_b3 === void 0 ? void 0 : _o5_b3.call(o5)["c"].d) === null || _o5_b_c_d3 === void 0 ? void 0 : _o5_b_c_d3["e"];
1414
(_o6 = o6()) === null || _o6 === void 0 ? void 0 : _o6["x"];
1515
// GH#36031
1616
o2 === null || o2 === void 0 ? void 0 : o2["b"].c;

‎crates/swc/tests/tsc-references/elementAccessChain.2.minified.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/swc/tests/tsc-references/exhaustiveSwitchStatements1.1.normal.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ Animal;
199199
Animal[Animal["CAT"] = 1] = "CAT";
200200
})(Animal || (Animal = {}));
201201
function expression() {
202-
var _ref;
203-
switch((_ref = zoo === null || zoo === void 0 ? void 0 : zoo.animal) !== null && _ref !== void 0 ? _ref : Animal.DOG){
202+
var _zoo_animal;
203+
switch((_zoo_animal = zoo === null || zoo === void 0 ? void 0 : zoo.animal) !== null && _zoo_animal !== void 0 ? _zoo_animal : Animal.DOG){
204204
case Animal.DOG:
205205
return Animal.DOG;
206206
case Animal.CAT:
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
//// [logicalAssignment8.ts]
22
function foo1(results) {
3-
var _ref;
4-
(results || (results = (_ref = bar === null || bar === void 0 ? void 0 : bar.value) !== null && _ref !== void 0 ? _ref : [])).push(100);
3+
var _bar_value;
4+
(results || (results = (_bar_value = bar === null || bar === void 0 ? void 0 : bar.value) !== null && _bar_value !== void 0 ? _bar_value : [])).push(100);
55
}
66
function foo2(results) {
7-
var _ref;
8-
(results !== null && results !== void 0 ? results : results = (_ref = bar === null || bar === void 0 ? void 0 : bar.value) !== null && _ref !== void 0 ? _ref : []).push(100);
7+
var _bar_value;
8+
(results !== null && results !== void 0 ? results : results = (_bar_value = bar === null || bar === void 0 ? void 0 : bar.value) !== null && _bar_value !== void 0 ? _bar_value : []).push(100);
99
}
1010
function foo3(results) {
11-
var _ref;
12-
(results && (results = (_ref = bar === null || bar === void 0 ? void 0 : bar.value) !== null && _ref !== void 0 ? _ref : [])).push(100);
11+
var _bar_value;
12+
(results && (results = (_bar_value = bar === null || bar === void 0 ? void 0 : bar.value) !== null && _bar_value !== void 0 ? _bar_value : [])).push(100);
1313
}

‎crates/swc/tests/tsc-references/nullishCoalescingOperator12.1.normal.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
const obj = {
33
arr: []
44
};
5-
var _ref;
6-
for (const i of (_ref = obj === null || obj === void 0 ? void 0 : obj.arr) !== null && _ref !== void 0 ? _ref : []){}
5+
var _obj_arr;
6+
for (const i of (_obj_arr = obj === null || obj === void 0 ? void 0 : obj.arr) !== null && _obj_arr !== void 0 ? _obj_arr : []){}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//// [nullishCoalescingOperator12.ts]
2-
var _ref;
2+
var _obj_arr;
33
const obj = {
44
arr: []
55
};
6-
for (const i of null !== (_ref = null == obj ? void 0 : obj.arr) && void 0 !== _ref ? _ref : []);
6+
for (const i of null !== (_obj_arr = null == obj ? void 0 : obj.arr) && void 0 !== _obj_arr ? _obj_arr : []);

‎crates/swc/tests/tsc-references/propertyAccessChain.1.normal.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//// [propertyAccessChain.ts]
2-
var _o3_b, _o4_b, _ref, _o5_b, _ref1, _o6;
2+
var _o3_b, _o4_b_c_d, _o4_b, _o5_b_c_d, _o5_b, _o6;
33
o1 === null || o1 === void 0 ? void 0 : o1.b;
44
o2 === null || o2 === void 0 ? void 0 : o2.b.c;
55
(_o3_b = o3.b) === null || _o3_b === void 0 ? void 0 : _o3_b.c;
6-
(_ref = (_o4_b = o4.b) === null || _o4_b === void 0 ? void 0 : _o4_b.c.d) === null || _ref === void 0 ? void 0 : _ref.e;
7-
(_ref1 = (_o5_b = o5.b) === null || _o5_b === void 0 ? void 0 : _o5_b.call(o5).c.d) === null || _ref1 === void 0 ? void 0 : _ref1.e;
6+
(_o4_b_c_d = (_o4_b = o4.b) === null || _o4_b === void 0 ? void 0 : _o4_b.c.d) === null || _o4_b_c_d === void 0 ? void 0 : _o4_b_c_d.e;
7+
(_o5_b_c_d = (_o5_b = o5.b) === null || _o5_b === void 0 ? void 0 : _o5_b.call(o5).c.d) === null || _o5_b_c_d === void 0 ? void 0 : _o5_b_c_d.e;
88
(_o6 = o6()) === null || _o6 === void 0 ? void 0 : _o6.x;
99
// GH#34109
1010
(o1 === null || o1 === void 0 ? void 0 : o1.b) ? 1 : 0;

‎crates/swc/tests/tsc-references/propertyAccessChain.2.minified.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/swc_ecma_transforms_compat/src/es2020/opt_chaining.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,7 @@ impl OptChaining {
380380
_ => {}
381381
}
382382

383-
e.base.visit_mut_children_with(self);
384-
385-
match &mut e.base {
383+
let mut base = match &mut e.base {
386384
OptChainBase::Member(MemberExpr { obj, prop, .. }) => {
387385
let obj_span = obj.span();
388386

@@ -548,7 +546,11 @@ impl OptChaining {
548546
alt,
549547
}
550548
}
551-
}
549+
};
550+
551+
base.visit_mut_with(self);
552+
553+
base
552554
}
553555
}
554556
#[derive(Default)]

‎crates/swc_ecma_transforms_compat/tests/es2020_optional_chaining.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -433,11 +433,11 @@ orders[client.key]?.price;
433433
434434
"#,
435435
r#"
436-
var _ref, _a_b, _ref1, _a_b_c, _a_b_c_d, _orders_, _orders_client_key, _c;
436+
var _a_b_c, _a_b_c_d, _a_b, _a_b_c1, _a_b_c_d1, _orders_, _orders_client_key, _c;
437437
foo === null || foo === void 0 ? void 0 : foo.bar;
438-
(_ref = a === null || a === void 0 ? void 0 : a.b.c) === null || _ref === void 0 ? void 0 : _ref.d.e;
439-
(_ref1 = (_a_b = a.b) === null || _a_b === void 0 ? void 0 : _a_b.c.d) === null || _ref1 === void 0 ? void 0 : _ref1.e;
440-
(_a_b_c = a.b.c) === null || _a_b_c === void 0 ? void 0 : (_a_b_c_d = _a_b_c.d) === null || _a_b_c_d === void 0 ? void 0 : _a_b_c_d.e;
438+
(_a_b_c = a === null || a === void 0 ? void 0 : a.b.c) === null || _a_b_c === void 0 ? void 0 : _a_b_c.d.e;
439+
(_a_b_c_d = (_a_b = a.b) === null || _a_b === void 0 ? void 0 : _a_b.c.d) === null || _a_b_c_d === void 0 ? void 0 : _a_b_c_d.e;
440+
(_a_b_c1 = a.b.c) === null || _a_b_c1 === void 0 ? void 0 : (_a_b_c_d1 = _a_b_c1.d) === null || _a_b_c_d1 === void 0 ? void 0 : _a_b_c_d1.e;
441441
orders === null || orders === void 0 ? void 0 : orders[0].price;
442442
orders === null || orders === void 0 ? void 0 : (_orders_ = orders[0]) === null || _orders_ === void 0 ? void 0 : _orders_.price;
443443
orders[client === null || client === void 0 ? void 0 : client.key].price;
@@ -518,7 +518,7 @@ foo?.bar()?.()
518518
519519
"#,
520520
r#"
521-
var _foo_bar, _foo_bar1, _foo, _foo_bar2, _foo_bar3, _foo_bar_call, _foo_bar4, _foo_bar5, _foo_bar_call1, _ref;
521+
var _foo_bar, _foo_bar1, _foo, _foo_bar2, _foo_bar3, _foo_bar_call, _foo_bar4, _foo_bar5, _foo_bar_call1, _foo_bar6;
522522
foo === null || foo === void 0 ? void 0 : foo(foo);
523523
foo === null || foo === void 0 ? void 0 : foo.bar();
524524
(_foo_bar = foo.bar) === null || _foo_bar === void 0 ? void 0 : _foo_bar.call(foo, foo.bar, false);
@@ -529,7 +529,7 @@ foo === null || foo === void 0 ? void 0 : (_foo = foo()) === null || _foo === vo
529529
(_foo_bar3 = foo.bar) === null || _foo_bar3 === void 0 ? void 0 : (_foo_bar_call = _foo_bar3.call(foo)) === null || _foo_bar_call === void 0 ? void 0 : _foo_bar_call.baz;
530530
foo === null || foo === void 0 ? void 0 : (_foo_bar4 = foo.bar) === null || _foo_bar4 === void 0 ? void 0 : _foo_bar4.call(foo).baz;
531531
foo === null || foo === void 0 ? void 0 : (_foo_bar5 = foo.bar) === null || _foo_bar5 === void 0 ? void 0 : (_foo_bar_call1 = _foo_bar5.call(foo)) === null || _foo_bar_call1 === void 0 ? void 0 : _foo_bar_call1.baz;
532-
(_ref = foo === null || foo === void 0 ? void 0 : foo.bar()) === null || _ref === void 0 ? void 0 : _ref();
532+
(_foo_bar6 = foo === null || foo === void 0 ? void 0 : foo.bar()) === null || _foo_bar6 === void 0 ? void 0 : _foo_bar6();
533533
"#
534534
);
535535

@@ -949,6 +949,13 @@ test!(
949949
"
950950
);
951951

952+
test_exec!(
953+
syntax(),
954+
|_| tr(Default::default()),
955+
issue_6346,
956+
"expect([1]?.filter(() => true).map?.(() => 2)).toEqual([2]);"
957+
);
958+
952959
test_exec!(
953960
ignore,
954961
syntax(),

‎crates/swc_ecma_utils/src/lib.rs

+25-3
Original file line numberDiff line numberDiff line change
@@ -1925,7 +1925,11 @@ pub fn alias_ident_for(expr: &Expr, default: &str) -> Ident {
19251925
ident: Some(ident), ..
19261926
}) => Some(ident.sym.to_string()),
19271927

1928-
Expr::Call(CallExpr {
1928+
Expr::OptChain(OptChainExpr {
1929+
base: OptChainBase::Call(OptCall { callee: expr, .. }),
1930+
..
1931+
})
1932+
| Expr::Call(CallExpr {
19291933
callee: Callee::Expr(expr),
19301934
..
19311935
}) => sym(expr),
@@ -1940,13 +1944,31 @@ pub fn alias_ident_for(expr: &Expr, default: &str) -> Ident {
19401944
..
19411945
}) => Some(format!("super_{}", sym(expr).unwrap_or_default())),
19421946

1943-
Expr::Member(MemberExpr {
1947+
Expr::OptChain(OptChainExpr {
1948+
base:
1949+
OptChainBase::Member(MemberExpr {
1950+
prop: MemberProp::Ident(ident),
1951+
obj,
1952+
..
1953+
}),
1954+
..
1955+
})
1956+
| Expr::Member(MemberExpr {
19441957
prop: MemberProp::Ident(ident),
19451958
obj,
19461959
..
19471960
}) => Some(format!("{}_{}", sym(obj).unwrap_or_default(), ident.sym)),
19481961

1949-
Expr::Member(MemberExpr {
1962+
Expr::OptChain(OptChainExpr {
1963+
base:
1964+
OptChainBase::Member(MemberExpr {
1965+
prop: MemberProp::Computed(ComputedPropName { expr, .. }),
1966+
obj,
1967+
..
1968+
}),
1969+
..
1970+
})
1971+
| Expr::Member(MemberExpr {
19501972
prop: MemberProp::Computed(ComputedPropName { expr, .. }),
19511973
obj,
19521974
..

1 commit comments

Comments
 (1)

github-actions[bot] commented on Nov 17, 2022

@github-actions[bot]

Benchmark

Benchmark suite Current: f7072db Previous: 7441721 Ratio
es/full/bugs-1 334805 ns/iter (± 18127) 336386 ns/iter (± 16008) 1.00
es/full/minify/libraries/antd 1780667832 ns/iter (± 17173485) 1829925137 ns/iter (± 19703431) 0.97
es/full/minify/libraries/d3 381082585 ns/iter (± 7200345) 394936502 ns/iter (± 14038189) 0.96
es/full/minify/libraries/echarts 1547630428 ns/iter (± 22586360) 1597043020 ns/iter (± 32949043) 0.97
es/full/minify/libraries/jquery 98626124 ns/iter (± 2971453) 112455796 ns/iter (± 3168567) 0.88
es/full/minify/libraries/lodash 116907486 ns/iter (± 3089676) 132469716 ns/iter (± 4546946) 0.88
es/full/minify/libraries/moment 58622385 ns/iter (± 2255961) 62608562 ns/iter (± 3260619) 0.94
es/full/minify/libraries/react 19450406 ns/iter (± 510833) 22530641 ns/iter (± 1009319) 0.86
es/full/minify/libraries/terser 289477464 ns/iter (± 7208734) 313290319 ns/iter (± 4965725) 0.92
es/full/minify/libraries/three 542243840 ns/iter (± 7665782) 565116172 ns/iter (± 15612929) 0.96
es/full/minify/libraries/typescript 3245973174 ns/iter (± 22954304) 3353129683 ns/iter (± 25602673) 0.97
es/full/minify/libraries/victory 789988605 ns/iter (± 10590936) 820400434 ns/iter (± 11924354) 0.96
es/full/minify/libraries/vue 148323945 ns/iter (± 3007185) 151618721 ns/iter (± 6198946) 0.98
es/full/codegen/es3 33414 ns/iter (± 1301) 33564 ns/iter (± 533) 1.00
es/full/codegen/es5 33367 ns/iter (± 804) 33552 ns/iter (± 322) 0.99
es/full/codegen/es2015 33589 ns/iter (± 1278) 33492 ns/iter (± 591) 1.00
es/full/codegen/es2016 33485 ns/iter (± 874) 33532 ns/iter (± 765) 1.00
es/full/codegen/es2017 33443 ns/iter (± 926) 33529 ns/iter (± 1367) 1.00
es/full/codegen/es2018 33490 ns/iter (± 1231) 33053 ns/iter (± 979) 1.01
es/full/codegen/es2019 33659 ns/iter (± 996) 33213 ns/iter (± 577) 1.01
es/full/codegen/es2020 33404 ns/iter (± 1846) 32598 ns/iter (± 1170) 1.02
es/full/all/es3 184563807 ns/iter (± 5806100) 189891800 ns/iter (± 5512388) 0.97
es/full/all/es5 174353068 ns/iter (± 5635998) 179208144 ns/iter (± 5100538) 0.97
es/full/all/es2015 139550268 ns/iter (± 2434944) 143821154 ns/iter (± 4045032) 0.97
es/full/all/es2016 138933989 ns/iter (± 3265699) 142141554 ns/iter (± 4979353) 0.98
es/full/all/es2017 137643683 ns/iter (± 2704993) 142283418 ns/iter (± 5250951) 0.97
es/full/all/es2018 136547949 ns/iter (± 3141469) 140380853 ns/iter (± 4125286) 0.97
es/full/all/es2019 136033205 ns/iter (± 2568960) 139195315 ns/iter (± 3421829) 0.98
es/full/all/es2020 130946022 ns/iter (± 2042192) 133959142 ns/iter (± 3532239) 0.98
es/full/parser 687876 ns/iter (± 29004) 721884 ns/iter (± 49747) 0.95
es/full/base/fixer 25829 ns/iter (± 857) 26238 ns/iter (± 1030) 0.98
es/full/base/resolver_and_hygiene 88804 ns/iter (± 3811) 91058 ns/iter (± 4382) 0.98
serialization of ast node 211 ns/iter (± 3) 217 ns/iter (± 2) 0.97
serialization of serde 218 ns/iter (± 5) 221 ns/iter (± 3) 0.99

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

Please sign in to comment.