fix(es/minifier): Report is_fn_local even if var is hoisted (#7876)

**Related issue:**
 - Closes #7847
This commit is contained in:
Austaras 2023-08-29 18:21:14 +08:00 committed by GitHub
parent c31f05a675
commit 87a47bfb2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 2 deletions

View File

@ -47,7 +47,6 @@ impl Optimizer<'_> {
// We only handle identifiers on lhs for now.
if let Some(lhs) = assign.left.as_ident() {
//
if self
.data
.vars

View File

@ -315,7 +315,7 @@ impl Storage for ProgramData {
}
}
ScopeKind::Block => {
if var_info.used_in_non_child_fn {
if e.get().used_in_non_child_fn {
e.get_mut().is_fn_local = false;
e.get_mut().used_in_non_child_fn = true;
}

View File

@ -0,0 +1,17 @@
function requireState() {
if (hasRequiredState) return state;
hasRequiredState = 1;
return state = {
getHighWaterMark: function(o) {
return o.objectMode ? 16 : 16384;
}
};
}
if (g()) {
var state, hasRequiredState;
const a = requireState()
console.log(a.getHighWaterMark())
const b = requireState()
console.log(b.getHighWaterMark())
}

View File

@ -0,0 +1,14 @@
function requireState() {
return hasRequiredState ? state : (hasRequiredState = 1, state = {
getHighWaterMark: function(o) {
return o.objectMode ? 16 : 16384;
}
});
}
if (g()) {
var state, hasRequiredState;
const a = requireState();
console.log(a.getHighWaterMark());
const b = requireState();
console.log(b.getHighWaterMark());
}