@@ -1198,11 +1198,9 @@ function OutputStream(options) {
|
|||||||
// need to take some precautions here:
|
// need to take some precautions here:
|
||||||
// https://github.com/mishoo/UglifyJS/issues/60
|
// https://github.com/mishoo/UglifyJS/issues/60
|
||||||
if (noin) node.walk(new TreeWalker(function(node) {
|
if (noin) node.walk(new TreeWalker(function(node) {
|
||||||
if (parens || node instanceof AST_Scope) return true;
|
if (parens) return true;
|
||||||
if (node instanceof AST_Binary && node.operator == "in") {
|
if (node instanceof AST_Binary && node.operator == "in") return parens = true;
|
||||||
parens = true;
|
if (node instanceof AST_Scope && !(node instanceof AST_Arrow && node.value)) return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}));
|
}));
|
||||||
node.print(output, parens);
|
node.print(output, parens);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,82 @@ await_parenthesis: {
|
|||||||
expect_exact: "async function f(){await(a=>a)}"
|
expect_exact: "async function f(){await(a=>a)}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for_parenthesis_init: {
|
||||||
|
input: {
|
||||||
|
for (a => (a in a); console.log(42););
|
||||||
|
}
|
||||||
|
expect_exact: "for((a=>a in a);console.log(42););"
|
||||||
|
expect_stdout: "42"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
for_parenthesis_condition: {
|
||||||
|
input: {
|
||||||
|
for (console.log(42); a => (a in a);)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
expect_exact: "for(console.log(42);a=>a in a;)break;"
|
||||||
|
expect_stdout: "42"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
for_parenthesis_step: {
|
||||||
|
input: {
|
||||||
|
for (; console.log(42); a => (a in a));
|
||||||
|
}
|
||||||
|
expect_exact: "for(;console.log(42);a=>a in a);"
|
||||||
|
expect_stdout: "42"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
for_assign_parenthesis_init: {
|
||||||
|
input: {
|
||||||
|
for (f = a => (a in a); console.log(42););
|
||||||
|
}
|
||||||
|
expect_exact: "for((f=a=>a in a);console.log(42););"
|
||||||
|
expect_stdout: "42"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
for_assign_parenthesis_condition: {
|
||||||
|
input: {
|
||||||
|
for (console.log(42); f = a => (a in a);)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
expect_exact: "for(console.log(42);f=a=>a in a;)break;"
|
||||||
|
expect_stdout: "42"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
for_assign_parenthesis_step: {
|
||||||
|
input: {
|
||||||
|
for (; console.log(42); f = a => (a in a));
|
||||||
|
}
|
||||||
|
expect_exact: "for(;console.log(42);f=a=>a in a);"
|
||||||
|
expect_stdout: "42"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
for_declaration_parenthesis_init: {
|
||||||
|
input: {
|
||||||
|
for (var f = a => (a in a); console.log(42););
|
||||||
|
}
|
||||||
|
expect_exact: "for(var f=(a=>a in a);console.log(42););"
|
||||||
|
expect_stdout: "42"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
for_statement_parenthesis_init: {
|
||||||
|
input: {
|
||||||
|
for (a => {
|
||||||
|
a in a;
|
||||||
|
}; console.log(42););
|
||||||
|
}
|
||||||
|
expect_exact: "for(a=>{a in a};console.log(42););"
|
||||||
|
expect_stdout: "42"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
body_call: {
|
body_call: {
|
||||||
input: {
|
input: {
|
||||||
(() => {
|
(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user