It's safe not to parenthesize SequenceExpressions in ReturnStatements

This commit is contained in:
Amjad Masad 2015-10-27 16:28:19 -07:00
parent 332bde6a0d
commit 84d80df181
3 changed files with 12 additions and 0 deletions

View File

@ -139,6 +139,10 @@ export function SequenceExpression(node, parent) {
return false;
}
if (t.isReturnStatement(parent)) {
return false;
}
// Otherwise err on the side of overparenthesization, adding
// explicit exceptions above if this proves overzealous.
return true;

View File

@ -5,3 +5,7 @@ function foo() {
function bar() {
return "foo";
}
function foo() {
return 1, "foo";
}

View File

@ -5,3 +5,7 @@ function foo() {
function bar() {
return "foo";
}
function foo() {
return 1, "foo";
}