Skip to content

Commit

Permalink
fix crash with error message and generic methods
Browse files Browse the repository at this point in the history
  • Loading branch information
dinfuehr committed Sep 25, 2020
1 parent a471b05 commit 401b10f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dora/src/typeck/lookup.rs
Expand Up @@ -283,11 +283,11 @@ impl<'a, 'ast> MethodLookup<'a, 'ast> {
let fct_params = fct
.params_without_self()
.iter()
.map(|a| a.name_fct(self.vm, self.caller))
.map(|a| a.name_fct(self.vm, &*fct))
.collect::<Vec<_>>();
let call_types = args
.iter()
.map(|a| a.name_fct(self.vm, self.caller))
.map(|a| a.name_fct(self.vm, &*fct))
.collect::<Vec<_>>();
let msg = SemError::ParamTypesIncompatible(fct_name, fct_params, call_types);
self.vm
Expand Down
12 changes: 12 additions & 0 deletions dora/src/typeck/tests.rs
Expand Up @@ -2212,3 +2212,15 @@ fn check_no_type_params_with_generic_type() {
fn enum_with_type_param() {
ok("enum MyOption[T: SomeTrait] { None, Some(T) }");
}

#[test]
fn check_wrong_number_type_params() {
err(
"
fun foo() { bar[Int32](false); }
fun bar[T](x: T) {}
",
pos(2, 35),
SemError::ParamTypesIncompatible("bar".into(), vec!["T".into()], vec!["Bool".into()]),
);
}

0 comments on commit 401b10f

Please sign in to comment.