aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2013-09-30 11:49:29 +0300
committerMihai Bazon <mihai@bazon.net>2013-09-30 11:49:29 +0300
commit95b4507c02b57ad15a50e4db7343bac250ed4460 (patch)
tree949119475df5ea8fdb75182539032355f480f8d3 /lib/compress.js
parentafdaeba37d2d7541529addaefe85ed09515863af (diff)
downloadtracifyjs-95b4507c02b57ad15a50e4db7343bac250ed4460.tar.gz
tracifyjs-95b4507c02b57ad15a50e4db7343bac250ed4460.zip
Fix error in the output minifying `Function("return this")()`
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 37aba41e..daac1c38 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1646,7 +1646,17 @@ merge(Compressor.prototype, {
ast = ast.transform(comp);
ast.figure_out_scope();
ast.mangle_names();
- var fun = ast.body[0].body.expression;
+ var fun;
+ try {
+ ast.walk(new TreeWalker(function(node){
+ if (node instanceof AST_Lambda) {
+ fun = node;
+ throw ast;
+ }
+ }));
+ } catch(ex) {
+ if (ex !== ast) throw ex;
+ };
var args = fun.argnames.map(function(arg, i){
return make_node(AST_String, self.args[i], {
value: arg.print_to_string()
@@ -1666,6 +1676,7 @@ merge(Compressor.prototype, {
compressor.warn(ex.toString());
} else {
console.log(ex);
+ throw ex;
}
}
}