aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoralexlamsl <alexlamsl@gmail.com>2017-02-18 18:58:23 +0800
committeralexlamsl <alexlamsl@gmail.com>2017-02-18 18:58:23 +0800
commit11676f9d72e667ea14ce380ed448da948e79f85e (patch)
treeb55b2578ae55d87bd4537565fc416c9944d3a22b /test
parentdd31d12a9110b34c1b45a72b6e1f2b64c2d7afe9 (diff)
downloadtracifyjs-11676f9d72e667ea14ce380ed448da948e79f85e.tar.gz
tracifyjs-11676f9d72e667ea14ce380ed448da948e79f85e.zip
fix crash in unsafe replacement of undefined
remove extraneous call to AST_SymbolRef.reference() closes #1443
Diffstat (limited to 'test')
-rw-r--r--test/compress/issue-1443.js69
1 files changed, 69 insertions, 0 deletions
diff --git a/test/compress/issue-1443.js b/test/compress/issue-1443.js
new file mode 100644
index 00000000..a2565872
--- /dev/null
+++ b/test/compress/issue-1443.js
@@ -0,0 +1,69 @@
+// tests assume that variable `undefined` not redefined and has `void 0` as value
+
+unsafe_undefined: {
+ options = {
+ if_return: true,
+ unsafe: true
+ }
+ mangle = {}
+ input: {
+ function f(undefined) {
+ return function() {
+ if (a)
+ return b;
+ if (c)
+ return d;
+ };
+ }
+ }
+ expect: {
+ function f(n) {
+ return function() {
+ if (a)
+ return b;
+ if (c)
+ return d;
+ else
+ return n;
+ };
+ }
+ }
+}
+
+keep_fnames: {
+ options = {
+ if_return: true,
+ unsafe: true
+ }
+ mangle = {
+ keep_fnames: true
+ }
+ input: {
+ function f(undefined) {
+ return function() {
+ function n(a) {
+ return a * a;
+ }
+ if (a)
+ return b;
+ if (c)
+ return d;
+ };
+ }
+ }
+ expect: {
+ function f(r) {
+ return function() {
+ function n(n) {
+ return n * n;
+ }
+ if (a)
+ return b;
+ if (c)
+ return d;
+ else
+ return r;
+ };
+ }
+ }
+}