Only assert that rigids are introduced at given rank behind flag

Closes #2489
This commit is contained in:
Ayaz Hafiz 2022-04-29 16:26:10 -04:00
parent 5e47e4767e
commit fe28d1554b
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
2 changed files with 24 additions and 7 deletions

View file

@ -678,6 +678,8 @@ fn solve(
pools.get_mut(next_rank).extend(pool_variables); pools.get_mut(next_rank).extend(pool_variables);
debug_assert_eq!( debug_assert_eq!(
// Check that no variable ended up in a higher rank than the next rank.. that
// would mean we generalized one level more than we need to!
{ {
let offenders = pools let offenders = pools
.get(next_rank) .get(next_rank)
@ -704,7 +706,7 @@ fn solve(
pools.get_mut(next_rank).clear(); pools.get_mut(next_rank).clear();
// check that things went well // check that things went well
debug_assert!({ if cfg!(debug_assertions) && std::env::var("ROC_VERIFY_RIGID_RANKS").is_ok() {
let rigid_vars = &constraints.variables[let_con.rigid_vars.indices()]; let rigid_vars = &constraints.variables[let_con.rigid_vars.indices()];
// NOTE the `subs.redundant` check does not come from elm. // NOTE the `subs.redundant` check does not come from elm.
@ -720,13 +722,9 @@ fn solve(
let failing: Vec<_> = it.collect(); let failing: Vec<_> = it.collect();
println!("Rigids {:?}", &rigid_vars); println!("Rigids {:?}", &rigid_vars);
println!("Failing {:?}", failing); println!("Failing {:?}", failing);
assert!(false)
// nicer error message
failing.is_empty()
} else {
true
} }
}); }
let mut new_env = env.clone(); let mut new_env = env.clone();
for (symbol, loc_var) in local_def_vars.iter() { for (symbol, loc_var) in local_def_vars.iter() {

View file

@ -6215,4 +6215,23 @@ mod solve_expr {
"a -> Task a *", "a -> Task a *",
); );
} }
#[test]
fn export_rigid_to_lower_rank() {
infer_eq_without_problem(
indoc!(
r#"
app "test" provides [ foo ] to "./platform"
F a : { foo : a }
foo = \arg ->
x : F b
x = arg
x.foo
"#
),
"F b -> b",
)
}
} }