Skip to content

Commit

Permalink
Merge pull request #187 from Schottkyc137/182-duplicate-declarations
Browse files Browse the repository at this point in the history
Fix: Allow components with the same name in different blocks
  • Loading branch information
kraigher authored Sep 8, 2023
2 parents b4c54a5 + d5b4a4b commit 5137bef
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vhdl_lang/src/analysis/concurrent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl<'a> AnalyzeContext<'a> {
}

self.define_labels_for_concurrent_part(
scope,
&nested,
parent,
&mut block.statements,
diagnostics,
Expand Down
2 changes: 2 additions & 0 deletions vhdl_lang/src/analysis/formal_region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ impl<'a> std::ops::Deref for GpkgInterfaceEnt<'a> {
GpkgInterfaceEnt::Type(typ) => typ.deref(),
GpkgInterfaceEnt::Constant(obj) => obj.deref(),
GpkgInterfaceEnt::Subprogram(subp) => subp.deref(),
// `ent` is of type `&&AnyEnt`. `deref()` returns `&AnyEnt` which is what we want
#[allow(suspicious_double_ref_op)]
GpkgInterfaceEnt::Package(ent) => ent.deref(),
}
}
Expand Down
30 changes: 30 additions & 0 deletions vhdl_lang/src/analysis/tests/homographs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,36 @@ end package;
check_no_diagnostics(&diagnostics);
}

#[test]
fn allow_homographs_in_separate_blocks() {
let mut builder = LibraryBuilder::new();
builder.code(
"libname",
"
entity A is
end A;
architecture arch of A is
component Z is end component;
begin
First : block
begin
Z_inst : Z;
end block;
Second : block
begin
Z_inst : Z;
end block;
end arch;
",
);

let diagnostics = builder.analyze();
check_no_diagnostics(&diagnostics);
}

#[test]
fn forbid_homographs() {
let mut builder = LibraryBuilder::new();
Expand Down

0 comments on commit 5137bef

Please sign in to comment.