Skip to content

Commit

Permalink
Merge ef99aaa into 98877f8
Browse files Browse the repository at this point in the history
  • Loading branch information
esdrubal committed Aug 28, 2024
2 parents 98877f8 + ef99aaa commit 0908ac4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions sway-core/src/semantic_analysis/ast_node/code_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ impl ty::TyCodeBlock {
}

ctx.engines.te().clear_unifications();
ctx.namespace()
.module(ctx.engines)
.current_lexical_scope()
.items
.clear_symbols_unique_while_collecting_unifications();

// We are typechecking the code block AST nodes twice.
// The first pass does all the unifications to the variables types.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl TyDecl {
.namespace()
.module(engines)
.current_items()
.check_symbol_unique(&var_decl.name.clone())
.check_symbols_unique_while_collecting_unifications(&var_decl.name.clone())
.ok();

if let Some(ResolvedDeclaration::Typed(ty::TyDecl::VariableDecl(
Expand Down
8 changes: 7 additions & 1 deletion sway-core/src/semantic_analysis/namespace/lexical_scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ impl Items {
})
}

pub(crate) fn check_symbol_unique(
pub(crate) fn check_symbols_unique_while_collecting_unifications(
&self,
name: &Ident,
) -> Result<ResolvedDeclaration, CompileError> {
Expand All @@ -718,6 +718,12 @@ impl Items {
})
}

pub(crate) fn clear_symbols_unique_while_collecting_unifications(&self) {
self.symbols_unique_while_collecting_unifications
.write()
.clear();
}

pub fn get_items_for_type(
&self,
engines: &Engines,
Expand Down
2 changes: 1 addition & 1 deletion sway-core/src/semantic_analysis/namespace/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl Module {
}

/// Returns the current lexical scope associated with this module.
fn current_lexical_scope(&self) -> &LexicalScope {
pub fn current_lexical_scope(&self) -> &LexicalScope {
self.lexical_scopes
.get(self.current_lexical_scope_id)
.unwrap()
Expand Down

0 comments on commit 0908ac4

Please sign in to comment.