Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

avoid some double-parens

(closes #368)
  • Loading branch information...
commit 67e6163441f2a475084f4e5c9506326021e3e37e 1 parent 24e0108
@mishoo authored
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/process.js
View
4 lib/process.js
@@ -1504,7 +1504,7 @@ function gen_code(ast, options) {
function parenthesize(expr) {
var gen = make(expr);
- for (var i = 1; i < arguments.length; ++i) {
+ if (!/^\(/.test(gen)) for (var i = 1; i < arguments.length; ++i) {
echo 'new ((0, Math) ? Function : Math)();' | uglifyjs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
var el = arguments[i];
if ((el instanceof Function && el(expr)) || expr[0] == el)
return "(" + gen + ")";
@@ -1659,7 +1659,7 @@ function gen_code(ast, options) {
if (expr[0] == "num") {
if (!/[a-f.]/i.test(out))
out += ".";
- } else if (expr[0] != "function" && needs_parens(expr))
+ } else if (expr[0] != "function" && !/^\(/.test(out) && needs_parens(expr))
echo '((0, 0) & 0).valueOf();' | uglifyjs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
out = "(" + out + ")";
while (i < arguments.length)
out += "." + make_name(arguments[i++]);

2 comments on commit 67e6163

@RGustBardon

The occurrence of a left parenthesis token as the first token of a PrimaryExpression does not imply that such an expression is parenthesized.

@RGustBardon
echo 'new ((0, Math) ? Function : Math)();' | uglifyjs
@RGustBardon
echo '((0, 0) & 0).valueOf();' | uglifyjs
@mishoo
Owner

Good catch, thanks.

Please sign in to comment.
Something went wrong with that request. Please try again.