diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-12-07 08:05:11 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-07 16:05:11 +0800 |
commit | fbecedf94ca2c2f667de39dff2d7fbb77629eb40 (patch) | |
tree | 5dd2d6d1a44f111cd2a81d6998d2442461ca1409 /lib/compress.js | |
parent | 2f31f950959b1dea835ad2d107148666412bd902 (diff) | |
download | tracifyjs-fbecedf94ca2c2f667de39dff2d7fbb77629eb40.tar.gz tracifyjs-fbecedf94ca2c2f667de39dff2d7fbb77629eb40.zip |
fix corner case in `evaluate` (#4341)
fixes #4340
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/compress.js b/lib/compress.js index 09b27635..be38304a 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -5115,7 +5115,7 @@ merge(Compressor.prototype, { } if (node === self) return; if (scope === self) { - if (node instanceof AST_AsyncDefun || node instanceof AST_Defun) { + if (is_defun(node)) { var def = node.name.definition(); if (!drop_funcs && !(def.id in in_use_ids)) { in_use_ids[def.id] = true; @@ -5266,7 +5266,7 @@ merge(Compressor.prototype, { if (node instanceof AST_Call) calls_to_drop_args.push(node); if (scope !== self) return; if (node instanceof AST_Lambda) { - if (drop_funcs && node !== self && (node instanceof AST_AsyncDefun || node instanceof AST_Defun)) { + if (drop_funcs && node !== self && is_defun(node)) { var def = node.name.definition(); if (!(def.id in in_use_ids)) { log(node.name, "Dropping unused function {name}"); @@ -7826,7 +7826,7 @@ merge(Compressor.prototype, { in_order = null; return; } - if (def.init instanceof AST_AsyncDefun || def.init instanceof AST_Defun) return abort = true; + if (is_defun(def.init)) return abort = true; if (is_lhs(node, this.parent())) return abort = true; var index = resolve_index(def); if (!(begin < index)) begin = index; @@ -7877,7 +7877,7 @@ merge(Compressor.prototype, { function can_inject_vars(defined, used, safe_to_inject) { for (var i = 0; i < fn.body.length; i++) { var stat = fn.body[i]; - if (stat instanceof AST_AsyncDefun || stat instanceof AST_Defun) { + if (is_defun(stat)) { if (!safe_to_inject || var_exists(used, stat.name.name)) return false; if (!all(stat.enclosed, function(def) { return def.scope === stat || !defined[def.name]; @@ -7925,9 +7925,7 @@ merge(Compressor.prototype, { fn.walk(new TreeWalker(function(node) { if (found) return true; if (node instanceof AST_Scope && node !== fn) { - if (node instanceof AST_AsyncDefun || node instanceof AST_Defun) { - if (node.name.name == "await") found = true; - } + if (is_defun(node) && node.name.name == "await") found = true; return true; } if (node instanceof AST_Symbol && node.name == "await" && node !== fn.name) return found = true; @@ -8027,7 +8025,7 @@ merge(Compressor.prototype, { flatten_vars(decls, expressions); expressions.push(value); var args = fn.body.filter(function(stat) { - if (stat instanceof AST_AsyncDefun || stat instanceof AST_Defun) { + if (is_defun(stat)) { var def = stat.name.definition(); scope.functions.set(def.name, def); scope.variables.set(def.name, def); |