Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit 731d793

Browse files
author
Hendrik van Antwerpen
committed
Ensure the resolved scope is added tot he correct scope stack, which may not be the precondition
1 parent b47eebf commit 731d793

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

stack-graphs/src/partial.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2378,10 +2378,22 @@ impl PartialPath {
23782378
if !graph[self.end_node].is_jump_to() {
23792379
return Ok(());
23802380
}
2381-
if self.scope_stack_postcondition.contains_scopes() {
2382-
return Err(PathResolutionError::ScopeStackUnsatisfied); // this path was not properly resolved
2383-
}
2384-
self.scope_stack_precondition.push_back(partials, node);
2381+
let scope_variable = match self.scope_stack_postcondition.variable() {
2382+
Some(scope_variable) => scope_variable,
2383+
None => return Err(PathResolutionError::ScopeStackUnsatisfied),
2384+
};
2385+
let mut scope_stack = PartialScopeStack::from_variable(scope_variable);
2386+
scope_stack.push_front(partials, node);
2387+
let mut scope_bindings = PartialScopeStackBindings::new();
2388+
scope_bindings
2389+
.add(partials, scope_variable, scope_stack)
2390+
.unwrap();
2391+
self.scope_stack_precondition
2392+
.apply_partial_bindings(partials, &scope_bindings)
2393+
.unwrap();
2394+
self.scope_stack_postcondition
2395+
.apply_partial_bindings(partials, &scope_bindings)
2396+
.unwrap();
23852397
self.end_node = node;
23862398
Ok(())
23872399
}
@@ -2561,9 +2573,7 @@ impl Node {
25612573
scope_stack: &mut PartialScopeStack,
25622574
) {
25632575
match self {
2564-
Node::DropScopes(_) => {
2565-
*scope_stack = PartialScopeStack::empty();
2566-
}
2576+
Node::DropScopes(_) => {}
25672577
Node::JumpTo(_) => {}
25682578
Node::PopScopedSymbol(node) => {
25692579
let symbol = symbol_stack

0 commit comments

Comments
 (0)