Skip to content

Commit 6ddd5e7

Browse files
committed
Fixes reference not set for selected function call without arguments. Closes #229
1 parent cd18c7e commit 6ddd5e7

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

vhdl_lang/src/analysis/names.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,8 @@ impl<'a> AnalyzeContext<'a> {
11251125
}
11261126
}
11271127
Disambiguated::Unambiguous(ent) => {
1128+
prefix.set_unique_reference(&ent);
1129+
11281130
if let Some(typ) = ent.return_type() {
11291131
resolved =
11301132
ResolvedName::Expression(DisambiguatedType::Unambiguous(typ));

vhdl_lang/src/analysis/tests/resolves_names.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,3 +2033,35 @@ end architecture;
20332033
);
20342034
}
20352035
}
2036+
2037+
/// This is a regression test for github issue #229
2038+
/// The reference was not set on the subprogram name when selected
2039+
#[test]
2040+
fn sets_reference_on_selected_subprogram_call() {
2041+
let mut builder = LibraryBuilder::new();
2042+
builder.code(
2043+
"libname",
2044+
"
2045+
entity ent is
2046+
end entity;
2047+
2048+
architecture a of ent is
2049+
type my_record_t is record
2050+
field1 : natural;
2051+
end record my_record_t;
2052+
2053+
function my_function return my_record_t is
2054+
begin
2055+
return (others => 0);
2056+
end function;
2057+
2058+
constant CONST1 : natural := my_function.field1;
2059+
begin
2060+
end architecture;
2061+
",
2062+
);
2063+
2064+
let (root, diagnostics) = builder.get_analyzed_root();
2065+
check_no_diagnostics(&diagnostics);
2066+
assert_eq!(root.find_all_unresolved().1, vec![]);
2067+
}

0 commit comments

Comments
 (0)