From 4b3c0652b776795b40ff6854dc2ccdf187e8947c Mon Sep 17 00:00:00 2001 From: kzc Date: Sat, 3 Feb 2018 01:51:19 -0500 Subject: [PATCH] fix `arguments` in arrow functions (#2877) --- lib/scope.js | 5 +++++ test/compress/harmony.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/lib/scope.js b/lib/scope.js index 7b2e4c02..09687aaf 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -383,6 +383,11 @@ AST_Lambda.DEFMETHOD("init_scope_vars", function(){ })); }); +AST_Arrow.DEFMETHOD("init_scope_vars", function(){ + AST_Scope.prototype.init_scope_vars.apply(this, arguments); + this.uses_arguments = false; +}); + AST_Symbol.DEFMETHOD("mark_enclosed", function(options) { var def = this.definition(); var s = this.scope; diff --git a/test/compress/harmony.js b/test/compress/harmony.js index 29a27b7d..ae85a337 100644 --- a/test/compress/harmony.js +++ b/test/compress/harmony.js @@ -1439,3 +1439,34 @@ issue_2794_6: { ] node_version: ">=6" } + +inline_arrow_using_arguments: { + options = { + evaluate: true, + inline: 1, + reduce_funcs: true, + reduce_vars: true, + sequences: true, + side_effects: true, + unused: true, + } + input: { + (function(){ + ((x) => { + console.log.apply(console, arguments), + console.log(x); + })(4); + })(3, 2, 1); + } + expect: { + (function(){ + console.log.apply(console, arguments), + console.log(4); + })(3, 2, 1); + } + expect_stdout: [ + "3 2 1", + "4", + ] + node_version: ">=6" +}