Skip to content

Commit

Permalink
fix(semantic): remove inherting ScopeFlags::Modifier from parent scope
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing committed Dec 16, 2024
1 parent 10a86b9 commit e7a4bfb
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions crates/oxc_semantic/src/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,10 @@ impl ScopeTree {
}

/// Get [`ScopeFlags`] for a new child scope under `parent_scope_id`.
pub fn get_new_scope_flags(
&self,
mut flags: ScopeFlags,
parent_scope_id: ScopeId,
) -> ScopeFlags {
pub fn get_new_scope_flags(&self, flags: ScopeFlags, parent_scope_id: ScopeId) -> ScopeFlags {
// https://tc39.es/ecma262/#sec-strict-mode-code
let parent_scope_flags = self.get_flags(parent_scope_id);
flags |= parent_scope_flags & ScopeFlags::StrictMode;

// inherit flags for non-function scopes
if !flags.contains(ScopeFlags::Function) {
flags |= parent_scope_flags & ScopeFlags::Modifiers;
}

flags
flags | parent_scope_flags & ScopeFlags::StrictMode
}

#[inline]
Expand Down

0 comments on commit e7a4bfb

Please sign in to comment.