Skip to content

Commit f672353

Browse files
author
sanex3339
committed
Added tests with optional chaining as a part of NewExpression callee
1 parent 2782a3e commit f672353

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

escodegen.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,8 +1897,11 @@
18971897
},
18981898

18991899
ChainExpression: function (expr, precedence, flags) {
1900-
var expression = expr.expression;
1901-
var result = this[expression.type](expression, precedence, flags);
1900+
if (Precedence.OptionalChaining < precedence) {
1901+
flags |= F_ALLOW_CALL;
1902+
}
1903+
1904+
var result = this.generateExpression(expr.expression, Precedence.OptionalChaining, flags);
19021905

19031906
return parenthesize(result, Precedence.OptionalChaining, precedence);
19041907
},

test/compare-acorn-es2020/optional-chaining.expected.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,8 @@ a?.b.c();
4040
(a?.b.c)();
4141
a.b?.().c;
4242
(a.b?.()).c;
43-
(a.b?.())?.c;
43+
(a.b?.())?.c;
44+
new (a?.b().c)();
45+
new (a?.b())();
46+
new (a?.b().c)();
47+
new (a?.b())();

test/compare-acorn-es2020/optional-chaining.expected.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/compare-acorn-es2020/optional-chaining.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,7 @@ a?.b.c();
4141
a.b?.().c;
4242
(a.b?.()).c;
4343
(a.b?.())?.c;
44+
new (a?.b().c);
45+
new (a?.b());
46+
new (a?.b().c)();
47+
new (a?.b())();

0 commit comments

Comments
 (0)