Skip to content

Commit

Permalink
refactor(semantic): remove defunct code setting ScopeFlags twice (#4286)
Browse files Browse the repository at this point in the history
Scope flags for functions is set when the scope is created. Remove redundant code that sets them again.
  • Loading branch information
overlookmotel committed Jul 16, 2024
1 parent 2c7bb9f commit c5731a5
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions crates/oxc_semantic/src/binder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,28 +151,16 @@ impl<'a> Binder for Function<'a> {
}
}

// bind scope flags: Constructor | GetAccessor | SetAccessor
if let Some(kind) = builder.nodes.parent_kind(builder.current_node_id) {
match kind {
AstKind::MethodDefinition(def) => {
let flag = builder.scope.get_flags_mut(current_scope_id);
*flag |= match def.kind {
MethodDefinitionKind::Constructor => ScopeFlags::Constructor,
MethodDefinitionKind::Get => ScopeFlags::GetAccessor,
MethodDefinitionKind::Set => ScopeFlags::SetAccessor,
MethodDefinitionKind::Method => ScopeFlags::empty(),
};
}
AstKind::ObjectProperty(prop) => {
let flag = builder.scope.get_flags_mut(current_scope_id);
*flag |= match prop.kind {
PropertyKind::Get => ScopeFlags::GetAccessor,
PropertyKind::Set => ScopeFlags::SetAccessor,
PropertyKind::Init => ScopeFlags::empty(),
};
}
_ => {}
}
// Bind scope flags: GetAccessor | SetAccessor
if let Some(AstKind::ObjectProperty(prop)) =
builder.nodes.parent_kind(builder.current_node_id)
{
let flag = builder.scope.get_flags_mut(current_scope_id);
match prop.kind {
PropertyKind::Get => *flag |= ScopeFlags::GetAccessor,
PropertyKind::Set => *flag |= ScopeFlags::SetAccessor,
PropertyKind::Init => {}
};
}
}
}
Expand Down

0 comments on commit c5731a5

Please sign in to comment.