diff --git a/lib/instrument/visitors/function.js b/lib/instrument/visitors/function.js index fa48a0ab..8541e773 100644 --- a/lib/instrument/visitors/function.js +++ b/lib/instrument/visitors/function.js @@ -577,6 +577,9 @@ function hoistSloppyFunctionDeclaration(declaration) { // In CommonJS code, file block is CommonJS wrapper function's params, and in any other context // file block contains no bindings except `this`. So it's safe to treat as a params block in all cases. // NB: `paramsBlockBinding.argNames` check is to avoid the pseudo-param `arguments` blocking hoisting. + // An actual param called `arguments` *does* prevent hoisting. + // e.g. `function f(arguments) { { function arguments() {} } return arguments; }` + // returns the value outer function is called with, not the inner function. const paramsBlockBinding = hoistBlock.parent.bindings.get(varName); if (paramsBlockBinding && !paramsBlockBinding.argNames) return;