Skip to content

Commit

Permalink
refactor(semantic): add strict mode in scope flags for class definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing committed Jul 10, 2024
1 parent b632c04 commit 45430cd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/oxc_semantic/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ impl<'a> SemanticBuilder<'a> {

pub fn strict_mode(&self) -> bool {
self.current_scope_flags().is_strict_mode()
|| self.current_node_flags.contains(NodeFlags::Class)
}

pub fn set_function_node_flag(&mut self, flag: NodeFlags) {
Expand Down Expand Up @@ -421,6 +420,12 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
if flags.contains(ScopeFlags::Top) { None } else { Some(self.current_scope_id) };

let mut flags = flags;

if !flags.is_strict_mode() && self.current_node_flags.has_class() {
// NOTE A class definition is always strict mode code.
flags |= ScopeFlags::StrictMode;
};

if let Some(parent_scope_id) = parent_scope_id {
flags = self.scope.get_new_scope_flags(flags, parent_scope_id);
}
Expand Down

0 comments on commit 45430cd

Please sign in to comment.