diff --git a/src/protocol/tests/parser_inference.rs b/src/protocol/tests/parser_inference.rs index bc374563dba2201bc6152c215cf42f1c536fef6b..e92d376247a919b7b119c7561a4ddb4e5ba9d200 100644 --- a/src/protocol/tests/parser_inference.rs +++ b/src/protocol/tests/parser_inference.rs @@ -428,4 +428,51 @@ fn test_failed_polymorph_inference() { } ", ); +} + + +#[test] +fn test_explicit_polymorph_argument() { + // Failed because array was put at same type depth as u32. So interpreted + // as a function with two polymorphic arguments + Tester::new_single_source_expect_ok("explicit with array", " + func foo(T a, T b) -> T { + return a @ b; + } + func test() -> u32 { + return foo({1}, {2})[1]; + }").for_function("test", |f| { f + .call_ok(Some(Value::UInt32(2))); + }); + + // Failed because type inferencer did not construct polymorph errors by + // considering that argument/return types failed against explicitly + // specified polymorphic arguments + Tester::new_single_source_expect_err("explicit polymorph mismatch", " + func foo(T a, T b) -> T { return a + b; } + struct Bar{A a, B b} + func test() -> u32 { + return foo[]>(5, 6); + }").error(|e| { e + .assert_num(2) + .assert_occurs_at(0, "foo[]") + .assert_msg_has(1, "inferred it to 'integerlike'"); + }); + + // Similar to above, now for return type + Tester::new_single_source_expect_err("explicit polymorph mismatch", " + func foo(T a, T b) -> T { return a + b; } + func test() -> u32 { + return foo(5, 6); + }").error(|e| { e + .assert_num(2) + .assert_occurs_at(0, "foo