treat wildcards as rigids

This commit is contained in:
Folkert 2021-05-03 20:39:06 +02:00
parent 84c46b94e2
commit 9b0e14ef4c
2 changed files with 57 additions and 9 deletions

View file

@ -155,8 +155,12 @@ where
}
}
for (var, lowercase) in output.introduced_variables.name_by_var.clone() {
rigid_variables.insert(var, lowercase);
for (var, lowercase) in output.introduced_variables.name_by_var {
rigid_variables.insert(var, lowercase.clone());
}
for var in output.introduced_variables.wildcards {
rigid_variables.insert(var, "*".into());
}
let mut references = MutSet::default();

View file

@ -71,6 +71,10 @@ mod test_reporting {
subs.rigid_var(var, name);
}
for var in output.introduced_variables.wildcards {
subs.rigid_var(var, "*".into());
}
let mut unify_problems = Vec::new();
let (_content, mut subs) = infer_expr(subs, &mut unify_problems, &constraint, var);
@ -6387,4 +6391,44 @@ mod test_reporting {
),
)
}
#[test]
fn num_too_general_wildcard() {
report_problem_as(
indoc!(
r#"
mult : Num *, F64 -> F64
mult = \a, b -> a * b
{}
"#
),
indoc!(
r#"
TYPE MISMATCH
"#
),
)
}
#[test]
fn num_too_general_named() {
report_problem_as(
indoc!(
r#"
mult : Num a, F64 -> F64
mult = \a, b -> a * b
{}
"#
),
indoc!(
r#"
TYPE MISMATCH
"#
),
)
}
}