diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-11-07 02:37:23 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-07 02:37:23 +0800 |
commit | bbedbf4ea03580c5b7aa39f32b92fdda9216c5b4 (patch) | |
tree | 8d2313be98b975b0b96ca36be869c172c3303599 /lib | |
parent | 2cfb5aa7dadd744bf7fbe16756696fc595f134a2 (diff) | |
download | tracifyjs-bbedbf4ea03580c5b7aa39f32b92fdda9216c5b4.tar.gz tracifyjs-bbedbf4ea03580c5b7aa39f32b92fdda9216c5b4.zip |
handle circular `function` reference gracefully (#2446)
fixes #2442
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js index c1232420..274ab604 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -4242,8 +4242,19 @@ merge(Compressor.prototype, { d.fixed = fixed = make_node(AST_Function, fixed, fixed); } if (fixed && d.single_use) { - var value = fixed.optimize(compressor); - return value === fixed ? fixed.clone(true) : value; + var recurse; + if (fixed instanceof AST_Function) { + for (var i = 0; recurse = compressor.parent(i); i++) { + if (recurse instanceof AST_Lambda) { + var name = recurse.name; + if (name && name.definition() === d) break; + } + } + } + if (!recurse) { + var value = fixed.optimize(compressor); + return value === fixed ? fixed.clone(true) : value; + } } if (fixed && d.should_replace === undefined) { var init; |