Skip to content

Commit

Permalink
Extract duplicated reference variable
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite committed Jul 8, 2024
1 parent 5b34383 commit 59d8b77
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions compiler/noirc_frontend/src/elaborator/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ impl<'context> Elaborator<'context> {
};

if let Some(unresolved_span) = typ.span {
let reference =
ReferenceId::Variable(Location::new(unresolved_span, self.file), is_self_type_name);

match resolved_type {
Type::Struct(ref struct_type, _) => {
// Record the location of the type reference
Expand All @@ -164,19 +167,11 @@ impl<'context> Elaborator<'context> {

if !is_synthetic {
let referenced = ReferenceId::Struct(struct_type.borrow().id);
let reference = ReferenceId::Variable(
Location::new(unresolved_span, self.file),
is_self_type_name,
);
self.interner.add_reference(referenced, reference);
}
}
Type::Alias(ref alias_type, _) => {
let referenced = ReferenceId::Alias(alias_type.borrow().id);
let reference = ReferenceId::Variable(
Location::new(unresolved_span, self.file),
is_self_type_name,
);
self.interner.add_reference(referenced, reference);
}
_ => (),
Expand Down

0 comments on commit 59d8b77

Please sign in to comment.