gets minified to {}.foo&&b() which causes a syntax error because {}.foo needs parens to be parsed as an expression.
A few other cases where object literals / object destructuring in expressions are getting parens stripped or would need them added, but not sure if they'd be related or need tackling separately:
({a, b, c} = d) -> {a,b,c}=d
truthyThing && {}.foo -> {}.foo
The less-contrived real-life example I'm running into is essentially the same as the first example (from setImmediate):
if ({}.toString.call(global.process) === "[object process]") { ...
For the if statements it could be as simple as making sure shouldParenthesiseTest is true if the test starts with {, but it feels like it might need a more general solution also incorporating those other cases.
The following example:
gets minified to
{}.foo&&b()
which causes a syntax error because{}.foo
needs parens to be parsed as an expression.A few other cases where object literals / object destructuring in expressions are getting parens stripped or would need them added, but not sure if they'd be related or need tackling separately:
({a, b, c} = d)
->{a,b,c}=d
truthyThing && {}.foo
->{}.foo
The less-contrived real-life example I'm running into is essentially the same as the first example (from setImmediate):
For the if statements it could be as simple as making sure
shouldParenthesiseTest
is true if the test starts with{
, but it feels like it might need a more general solution also incorporating those other cases.