Added parens around in operator in for loops 🚀. (#468)

This commit is contained in:
Davy Duperron authored and Christopher Chedeau committed 2017-01-25 14:24:25 -08:00
1 parent 620cb7be19
commit 03b4ed2fcf
3 files changed
+11

No files matched your search

+7
View File
@@ -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
View File
@@ -1 +1,2 @@
for ((x in a);;) {}
for (a=(a in b);;) {}