Skip to content

Commit 17199d4

Browse files
committed
Handle disambiguation with universal target type
1 parent 5e322f6 commit 17199d4

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

vhdl_lang/src/analysis/expression.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,4 +1601,31 @@ function \"+\"(a : integer; b : character) return integer;
16011601
))
16021602
);
16031603
}
1604+
1605+
#[test]
1606+
fn universal_integer_target_type_accepts_integer() {
1607+
let test = TestSetup::new();
1608+
test.declarative_part(
1609+
"
1610+
function no_arg return boolean;
1611+
function no_arg return integer;
1612+
function with_arg(arg : natural) return boolean;
1613+
function with_arg(arg : natural) return integer;
1614+
1615+
",
1616+
);
1617+
1618+
let code = test.snippet("no_arg");
1619+
test.expr_with_ttyp(
1620+
&code,
1621+
test.ctx().universal_integer().into(),
1622+
&mut NoDiagnostics,
1623+
);
1624+
let code = test.snippet("with_arg(0)");
1625+
test.expr_with_ttyp(
1626+
&code,
1627+
test.ctx().universal_integer().into(),
1628+
&mut NoDiagnostics,
1629+
);
1630+
}
16041631
}

vhdl_lang/src/analysis/overloaded.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ impl<'a> AnalyzeContext<'a> {
319319

320320
let ok_return_type = if let SubprogramKind::Function(rtyp) = kind {
321321
let mut ok_return_type = ok_assoc_types.clone();
322-
self.implicit_matcher()
322+
self.any_matcher()
323323
.disambiguate_op_by_return_type(&mut ok_return_type, rtyp);
324324

325325
// Only one candidate matches type profile, check it

0 commit comments

Comments
 (0)