diff --git a/src/fast-path.js b/src/fast-path.js index a8dcc88fd..af44e0c9f 100644 --- a/src/fast-path.js +++ b/src/fast-path.js @@ -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": diff --git a/tests/for/__snapshots__/jsfmt.spec.js.snap b/tests/for/__snapshots__/jsfmt.spec.js.snap index 7ec23d49d..a6f873b0b 100644 --- a/tests/for/__snapshots__/jsfmt.spec.js.snap +++ b/tests/for/__snapshots__/jsfmt.spec.js.snap @@ -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); ; ) { +} " `; diff --git a/tests/for/in.js b/tests/for/in.js index 5fb450d16..d88f2c6f1 100644 --- a/tests/for/in.js +++ b/tests/for/in.js @@ -1 +1,2 @@ for ((x in a);;) {} +for (a=(a in b);;) {}