fix bug in uniq isEq type

it always wanted Boolean arguments ...
This commit is contained in:
Folkert 2020-03-13 13:06:37 +01:00
parent e01a6bab9b
commit 9ef4a6d891
2 changed files with 25 additions and 11 deletions

View file

@ -397,13 +397,13 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
// isEq or (==) : Attr u1 Bool, Attr u2 Bool -> Attr u3 Bool // isEq or (==) : Attr u1 Bool, Attr u2 Bool -> Attr u3 Bool
add_type( add_type(
Symbol::BOOL_EQ, Symbol::BOOL_EQ,
unique_function(vec![bool_type(UVAR1), bool_type(UVAR2)], bool_type(UVAR3)), unique_function(vec![flex(TVAR1), flex(TVAR2)], bool_type(UVAR3)),
); );
// isNeq or (!=) : Attr u1 Bool, Attr u2 Bool -> Attr u3 Bool // isNeq or (!=) : Attr u1 Bool, Attr u2 Bool -> Attr u3 Bool
add_type( add_type(
Symbol::BOOL_NEQ, Symbol::BOOL_NEQ,
unique_function(vec![bool_type(UVAR1), bool_type(UVAR2)], bool_type(UVAR3)), unique_function(vec![flex(TVAR1), flex(TVAR2)], bool_type(UVAR3)),
); );
// and or (&&) : Attr u1 Bool, Attr u2 Bool -> Attr u3 Bool // and or (&&) : Attr u1 Bool, Attr u2 Bool -> Attr u3 Bool

View file

@ -1408,6 +1408,7 @@ mod test_uniq_solve {
#[test] #[test]
fn quicksort() { fn quicksort() {
with_larger_debug_stack(|| {
infer_eq( infer_eq(
indoc!( indoc!(
r#" r#"
@ -1462,6 +1463,7 @@ mod test_uniq_solve {
), ),
"Attr Shared (Attr b (List (Attr Shared (Num (Attr c a)))), Attr Shared Int, Attr Shared Int -> Attr b (List (Attr Shared (Num (Attr c a)))))" "Attr Shared (Attr b (List (Attr Shared (Num (Attr c a)))), Attr Shared Int, Attr Shared Int -> Attr b (List (Attr Shared (Num (Attr c a)))))"
); );
})
} }
#[test] #[test]
@ -2083,7 +2085,8 @@ mod test_uniq_solve {
reverse reverse
"# "#
), ),
"Attr * (Attr * (List (Attr (a | b) c)) -> Attr (* | a | b) (List (Attr a c)))", "Attr * (Attr * (List (Attr (a | b) c)) -> Attr (* | a | b) (List (Attr b c)))",
//"Attr * (Attr * (List (Attr (a | b) c)) -> Attr (* | a | b) (List (Attr a c)))",
); );
} }
@ -2327,7 +2330,6 @@ mod test_uniq_solve {
Ok (reconstructPath model.cameFrom goal) Ok (reconstructPath model.cameFrom goal)
else else
modelPopped = { model & openSet : Set.remove model.openSet current, evaluated : Set.insert model.evaluated current } modelPopped = { model & openSet : Set.remove model.openSet current, evaluated : Set.insert model.evaluated current }
neighbours = moveFn current neighbours = moveFn current
@ -2348,6 +2350,18 @@ mod test_uniq_solve {
}); });
} }
#[test]
fn equals() {
infer_eq(
indoc!(
r#"
\a, b -> a == b
"#
),
"Attr * (*, * -> Attr * Bool)",
);
}
#[test] #[test]
fn instantiated_alias() { fn instantiated_alias() {
infer_eq( infer_eq(