Check shadow variable to identifier in default parameters (#10053)
When there is a variable declaration inside the function body, which shares its name to a referenced identifier in default parameter expression, the function body should be wrapped into iife, otherwise the binding in default parameter scope will be shadowed by function body.
This commit is contained in:
committed by
Nicolò Ribaudo
parent
0b3f883ed1
commit
bffa415b83
@@ -32,7 +32,11 @@ function isSafeBinding(scope, node) {
|
||||
const iifeVisitor = {
|
||||
ReferencedIdentifier(path, state) {
|
||||
const { scope, node } = path;
|
||||
if (node.name === "eval" || !isSafeBinding(scope, node)) {
|
||||
if (
|
||||
node.name === "eval" ||
|
||||
!isSafeBinding(scope, node) ||
|
||||
!isSafeBinding(state.scope, node)
|
||||
) {
|
||||
state.iife = true;
|
||||
path.stop();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user