}
else if (compressor.option("warnings")) {
stat.walk(new TreeWalker(function(node){
- if (node instanceof AST_Definitions
- || node instanceof AST_Defun) {
+ if (node instanceof AST_Definitions || node instanceof AST_Defun) {
compressor.warn("Declarations in unreachable code! [{line},{col}]", node.start);
if (node instanceof AST_Definitions) {
node = node.clone();
else if (node instanceof AST_Defun) {
a.push(node);
}
- return true;
+ return true; // no point to descend
}
- if (node instanceof AST_Scope)
+ if (node instanceof AST_Scope) {
+ // also don't descend any other nested scopes
return true;
- }))
+ }
+ }));
};
} else {
a.push(stat);
}, []);
}
+ // XXX: this is destructive -- it modifies tree nodes.
function sequencesize(statements) {
var prev = null, last = statements.length - 1;
if (last) statements = statements.reduce(function(a, cur, i){
});
prev.body = seq;
}
- else if (i == last && cur instanceof AST_Exit
- && cur.value && a.length == 1) {
+ else if (i == last
+ && cur instanceof AST_Exit && cur.value
+ && a.length == 1 && prev instanceof AST_SimpleStatement) {
// it only makes sense to do this transformation
// if the AST gets to a single statement.
var seq = make_node(AST_Seq, prev, {