diff --git a/lib/compress.js b/lib/compress.js index 531c9aad..6c26e8a9 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -5659,7 +5659,7 @@ merge(Compressor.prototype, { var defun = make_node(AST_Defun, def, def.value); defun.name = make_node(AST_SymbolDefun, def.name, def.name); var name_def = def.name.scope.resolve().def_function(defun.name); - if (old_def) old_def.references.forEach(function(node) { + if (old_def) old_def.forEach(function(node) { node.name = name_def.name; node.thedef = name_def; node.reference({}); diff --git a/test/compress/hoist_vars.js b/test/compress/hoist_vars.js index 6cd99b06..173aaeaf 100644 --- a/test/compress/hoist_vars.js +++ b/test/compress/hoist_vars.js @@ -134,3 +134,27 @@ issue_2295: { } } } + +issue_4487: { + options = { + functions: true, + hoist_vars: true, + keep_fnames: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + var a = function f() { + var f = console.log(typeof f); + }; + var b = a(); + } + expect: { + function a() { + var a = console.log(typeof a); + } + a(); + } + expect_stdout: "undefined" +}