[Pkg-javascript-commits] [uglifyjs] 01/26: Fix parens for AST_Undefined
Jonas Smedegaard
dr at jones.dk
Tue May 19 00:02:20 UTC 2015
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag v2.4.16
in repository uglifyjs.
commit 62bda71c853e844f0477873397ae7ae211bc7dc8
Author: Mihai Bazon <mihai at bazon.net>
Date: Fri Jul 18 11:31:41 2014 +0300
Fix parens for AST_Undefined
Do the same as for AST_Unary, since we output undefined as `void 0`.
Reported at https://github.com/mishoo/UglifyJS2/issues/338#issuecomment-48858341
---
lib/output.js | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/lib/output.js b/lib/output.js
index 6c8f15a..7fe61af 100644
--- a/lib/output.js
+++ b/lib/output.js
@@ -434,7 +434,13 @@ function OutputStream(options) {
/* -----[ PARENTHESES ]----- */
function PARENS(nodetype, func) {
- nodetype.DEFMETHOD("needs_parens", func);
+ if (Array.isArray(nodetype)) {
+ nodetype.forEach(function(nodetype){
+ PARENS(nodetype, func);
+ });
+ } else {
+ nodetype.DEFMETHOD("needs_parens", func);
+ }
};
PARENS(AST_Node, function(){
@@ -453,7 +459,7 @@ function OutputStream(options) {
return first_in_statement(output);
});
- PARENS(AST_Unary, function(output){
+ PARENS([ AST_Unary, AST_Undefined ], function(output){
var p = output.parent();
return p instanceof AST_PropAccess && p.expression === this;
});
@@ -549,7 +555,7 @@ function OutputStream(options) {
return true;
});
- function assign_and_conditional_paren_rules(output) {
+ PARENS([ AST_Assign, AST_Conditional ], function (output){
var p = output.parent();
// !(a = false) → true
if (p instanceof AST_Unary)
@@ -566,10 +572,7 @@ function OutputStream(options) {
// (a = foo)["prop"] —or— (a = foo).prop
if (p instanceof AST_PropAccess && p.expression === this)
return true;
- };
-
- PARENS(AST_Assign, assign_and_conditional_paren_rules);
- PARENS(AST_Conditional, assign_and_conditional_paren_rules);
+ });
/* -----[ PRINTERS ]----- */
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git
More information about the Pkg-javascript-commits
mailing list