Added parens around in operator in for loops 🚀. (#468)
This commit is contained in:
1 parent
620cb7be19
commit
03b4ed2fcf
3 files changed
+11
No files matched your search
@@ -276,6 +276,13 @@ FPp.needsParens = function(assumeExpressionContext) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
node.operator === 'in' &&
|
||||
parent.type === 'AssignmentExpression'
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
case "LogicalExpression":
|
||||
switch (parent.type) {
|
||||
case "CallExpression":
|
||||
|
||||
@@ -11,9 +11,12 @@ for (var i = 0; i < 10; ++i) {
|
||||
|
||||
exports[`test in.js 1`] = `
|
||||
"for ((x in a);;) {}
|
||||
for (a=(a in b);;) {}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
for ((x in a); ; ) {
|
||||
}
|
||||
for (a = (a in b); ; ) {
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
for ((x in a);;) {}
|
||||
for (a=(a in b);;) {}
|
||||
Reference in new issue
Block a user