Skip to content

semantic: directly record real node ID when adding a scope to the scope-tree #4234

@lucab

Description

@lucab

From #4208 (comment):

Once #4203 is merged, node IDs will be generated before scope is created, so we can add node_id to params of this function, and push the actual AstNodeId here. Then we can remove set_node_id.

In particular, this is about refactoring the logic here below and getting rid of the dummy node ID:

pub fn add_scope(&mut self, parent_id: Option<ScopeId>, flags: ScopeFlags) -> ScopeId {
let scope_id = self.parent_ids.push(parent_id);
_ = self.child_ids.push(vec![]);
_ = self.flags.push(flags);
_ = self.bindings.push(Bindings::default());
_ = self.node_ids.push(AstNodeId::dummy());
// Set this scope as child of parent scope.
if let Some(parent_id) = parent_id {
self.child_ids[parent_id].push(scope_id);
}
scope_id
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-semanticArea - SemanticC-cleanupCategory - technical debt or refactoring. Solution not expected to change behavior

    Type

    No type

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions