aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-03-17 00:26:48 +0800
committerGitHub <noreply@github.com>2017-03-17 00:26:48 +0800
commitac403018135b0ba700ef6223970c1bbc2a518107 (patch)
treefafe0f1088d30ba7e599c76cb4663fe9a4e96571 /test
parent3563d8c09e36be8f8b9cb9500852778f8d191d5d (diff)
downloadtracifyjs-ac403018135b0ba700ef6223970c1bbc2a518107.tar.gz
tracifyjs-ac403018135b0ba700ef6223970c1bbc2a518107.zip
fix chained evaluation (#1610)
`reduce_vars` enables substitution of variables but did not clone the value's `AST_Node`. This confuses `collapse_vars` and result in invalid AST and subsequent crash. fixes #1609
Diffstat (limited to 'test')
-rw-r--r--test/compress/issue-1609.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/compress/issue-1609.js b/test/compress/issue-1609.js
new file mode 100644
index 00000000..577a3ee1
--- /dev/null
+++ b/test/compress/issue-1609.js
@@ -0,0 +1,56 @@
+chained_evaluation_1: {
+ options = {
+ collapse_vars: true,
+ evaluate: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ (function() {
+ var a = 1;
+ (function() {
+ var b = a, c;
+ c = f(b);
+ c.bar = b;
+ })();
+ })();
+ }
+ expect: {
+ (function() {
+ (function() {
+ var c;
+ c = f(1);
+ c.bar = 1;
+ })();
+ })();
+ }
+}
+
+chained_evaluation_2: {
+ options = {
+ collapse_vars: true,
+ evaluate: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ (function() {
+ var a = "long piece of string";
+ (function() {
+ var b = a, c;
+ c = f(b);
+ c.bar = b;
+ })();
+ })();
+ }
+ expect: {
+ (function() {
+ var a = "long piece of string";
+ (function() {
+ var c;
+ c = f(a);
+ c.bar = a;
+ })();
+ })();
+ }
+}