refactor(semantic): simplify setting scope flags (#4674)

This commit is contained in:
overlookmotel 2024-08-05 23:47:43 +01:00 committed by GitHub
parent 6e453db3f7
commit 09d982224f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -510,15 +510,9 @@ impl<'a> SemanticBuilder<'a> {
impl<'a> Visit<'a> for SemanticBuilder<'a> {
// NB: Not called for `Program`
fn enter_scope(&mut self, mut flags: ScopeFlags, scope_id: &Cell<Option<ScopeId>>) {
fn enter_scope(&mut self, flags: ScopeFlags, scope_id: &Cell<Option<ScopeId>>) {
let parent_scope_id = self.current_scope_id;
if !flags.is_strict_mode() && self.current_node_flags.has_class() {
// NOTE A class definition is always strict mode code.
flags |= ScopeFlags::StrictMode;
};
flags = self.scope.get_new_scope_flags(flags, parent_scope_id);
let flags = self.scope.get_new_scope_flags(flags, parent_scope_id);
self.current_scope_id = self.scope.add_scope(parent_scope_id, self.current_node_id, flags);
scope_id.set(Some(self.current_scope_id));