diff options
author | Mihai Bazon <mihai@bazon.net> | 2012-10-13 12:56:56 +0300 |
---|---|---|
committer | Mihai Bazon <mihai@bazon.net> | 2012-10-13 12:57:10 +0300 |
commit | 851b48e4a3ecdbe7d77ec827f94d67092d2890ef (patch) | |
tree | d4635ed724708705b6ffa94bc87421d96a0f4533 | |
parent | 708abb1ab141c737a70fca9e0af839a0b68d9db0 (diff) | |
download | tracifyjs-851b48e4a3ecdbe7d77ec827f94d67092d2890ef.tar.gz tracifyjs-851b48e4a3ecdbe7d77ec827f94d67092d2890ef.zip |
fix compressing benchmark.js (it tried to evaluate a statement)
the following code in benchmark.js triggered the issue:
support.decompilation = Function(
'return (' + (function(x) { return { 'x': '' + (1 + x) + '', 'y': 0 }; }) + ')'
)()(0).x === '1';
technically that could be resolved into a constant expression, but seems
it's being used here for browser bugs detection :-\
-rw-r--r-- | lib/compress.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js index c13421ea..78d9d0c0 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -534,7 +534,14 @@ merge(Compressor.prototype, { } }); def(AST_Statement, function(){ - throw new Error("Cannot evaluate a statement"); + throw new Error(string_template("Cannot evaluate a statement [{file}:{line},{col}]", this.start)); + }); + def(AST_Function, function(){ + // XXX: AST_Function inherits from AST_Scope, which itself + // inherits from AST_Statement; however, an AST_Function + // isn't really a statement. This could byte in other + // places too. :-( Wish JS had multiple inheritance. + return [ this ]; }); function ev(node) { return node._eval(); |