mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
treat wildcards as rigids
This commit is contained in:
parent
84c46b94e2
commit
9b0e14ef4c
2 changed files with 57 additions and 9 deletions
|
@ -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();
|
||||
|
|
|
@ -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 ───────────────────────────────────────────────────────────────
|
||||
|
||||
"#
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue