add tests for the rigid issue

This commit is contained in:
Folkert 2020-11-11 22:54:15 +01:00
parent 22592eff80
commit 21685b6f8f
3 changed files with 31 additions and 1 deletions

View File

@ -11,6 +11,7 @@ use roc_region::all::{Located, Region};
use roc_types::subs::Variable;
use roc_types::types::{Category, PReason, PatternCategory, Reason, RecordField, Type};
#[derive(Default)]
pub struct PatternState {
pub headers: SendMap<Symbol, Located<Type>>,
pub vars: Vec<Variable>,

View File

@ -1148,7 +1148,7 @@ mod gen_primitives {
ConsList a : [ Cons a (ConsList a), Nil ]
# isEmpty : ConsList a -> Bool
isEmpty : ConsList a -> Bool
isEmpty = \list ->
when list is
Cons _ _ ->

View File

@ -3106,4 +3106,33 @@ mod solve_expr {
"Dict Int Int",
);
}
#[test]
fn rbtree_insert() {
// exposed an issue where pattern variables were not introduced
// at the correct level in the constraint
//
// see 22592eff805511fbe1da63849771ee5f367a6a16
infer_eq_without_problem(
indoc!(
r#"
app Test provides [ main ] imports []
Dict k : [ Node k (Dict k), Empty ]
balance : Dict k -> Dict k
balance = \left ->
when left is
Node _ Empty -> Empty
_ -> Empty
main : Dict {}
main =
balance Empty
"#
),
"Dict {}",
);
}
}