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
add_type(
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
add_type(
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

View File

@ -1408,7 +1408,8 @@ mod test_uniq_solve {
#[test]
fn quicksort() {
infer_eq(
with_larger_debug_stack(|| {
infer_eq(
indoc!(
r#"
quicksort : List (Num a), Int, Int -> List (Num a)
@ -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)))))"
);
})
}
#[test]
@ -2083,7 +2085,8 @@ mod test_uniq_solve {
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,18 +2330,17 @@ mod test_uniq_solve {
Ok (reconstructPath model.cameFrom goal)
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
newNeighbours = Set.diff neighbours modelPopped.evaluated
newNeighbours = Set.diff neighbours modelPopped.evaluated
modelWithNeighbours = { modelPopped & openSet : Set.union modelPopped.openSet newNeighbours }
modelWithNeighbours = { modelPopped & openSet : Set.union modelPopped.openSet newNeighbours }
modelWithCosts = Set.foldl newNeighbours (\nb, md -> updateCost current nb md) modelWithNeighbours
modelWithCosts = Set.foldl newNeighbours (\nb, md -> updateCost current nb md) modelWithNeighbours
astar costFn moveFn goal modelWithCosts
astar costFn moveFn goal modelWithCosts
findPath
"#
@ -2348,6 +2350,18 @@ mod test_uniq_solve {
});
}
#[test]
fn equals() {
infer_eq(
indoc!(
r#"
\a, b -> a == b
"#
),
"Attr * (*, * -> Attr * Bool)",
);
}
#[test]
fn instantiated_alias() {
infer_eq(