Skip to content

Commit 07ffac8

Browse files
committed
Support instantiating empty components
1 parent 86ee6c7 commit 07ffac8

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

vhdl_lang/src/analysis/semantic.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,32 @@ impl<'a> AnalyzeContext<'a> {
200200
None => {}
201201
}
202202
}
203+
ResolvedName::Final(ent) => {
204+
if let AnyEntKind::Component(region) = ent.kind() {
205+
name.set_unique_reference(ent);
206+
let (generic_region, port_region) = region.to_entity_formal();
207+
self.analyze_assoc_elems_with_formal_region(
208+
&fcall.item.name.pos,
209+
&generic_region,
210+
scope,
211+
&mut [],
212+
diagnostics,
213+
)?;
214+
self.analyze_assoc_elems_with_formal_region(
215+
&fcall.item.name.pos,
216+
&port_region,
217+
scope,
218+
&mut [],
219+
diagnostics,
220+
)?;
221+
} else {
222+
diagnostics.push(Diagnostic::error(
223+
&name.pos,
224+
format!("{} is not a procedure", resolved.describe_type()),
225+
));
226+
self.analyze_assoc_elems(scope, parameters, diagnostics)?;
227+
}
228+
}
203229
resolved => {
204230
diagnostics.push(Diagnostic::error(
205231
&name.pos,

vhdl_lang/src/analysis/tests/resolves_design_units.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,3 +502,33 @@ end architecture;
502502
)],
503503
);
504504
}
505+
506+
#[test]
507+
fn empty_component_instantiation() {
508+
let mut builder = LibraryBuilder::new();
509+
let code = builder.code(
510+
"libname",
511+
"
512+
entity ent is
513+
end entity;
514+
515+
architecture a of ent is
516+
component empty
517+
end component;
518+
begin
519+
inst: empty;
520+
end architecture;
521+
522+
523+
",
524+
);
525+
526+
let (root, diagnostics) = builder.get_analyzed_root();
527+
check_no_diagnostics(&diagnostics);
528+
assert_eq!(
529+
root.search_reference(code.source(), code.sa("inst: ", "empty").start())
530+
.unwrap()
531+
.decl_pos(),
532+
Some(&code.s1("empty").pos())
533+
);
534+
}

0 commit comments

Comments
 (0)