Skip to content

Commit

Permalink
Added tests with optional chaining as a part of NewExpression callee
Browse files Browse the repository at this point in the history
  • Loading branch information
sanex3339 committed Aug 5, 2020
1 parent 2782a3e commit f672353
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
7 changes: 5 additions & 2 deletions escodegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -1897,8 +1897,11 @@
},

ChainExpression: function (expr, precedence, flags) {
var expression = expr.expression;
var result = this[expression.type](expression, precedence, flags);
if (Precedence.OptionalChaining < precedence) {
flags |= F_ALLOW_CALL;
}

var result = this.generateExpression(expr.expression, Precedence.OptionalChaining, flags);

return parenthesize(result, Precedence.OptionalChaining, precedence);
},
Expand Down
6 changes: 5 additions & 1 deletion test/compare-acorn-es2020/optional-chaining.expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,8 @@ a?.b.c();
(a?.b.c)();
a.b?.().c;
(a.b?.()).c;
(a.b?.())?.c;
(a.b?.())?.c;
new (a?.b().c)();
new (a?.b())();
new (a?.b().c)();
new (a?.b())();

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions test/compare-acorn-es2020/optional-chaining.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ a?.b.c();
a.b?.().c;
(a.b?.()).c;
(a.b?.())?.c;
new (a?.b().c);
new (a?.b());
new (a?.b().c)();
new (a?.b())();

0 comments on commit f672353

Please sign in to comment.