mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +00:00
fix bug in uniq isEq type
it always wanted Boolean arguments ...
This commit is contained in:
parent
e01a6bab9b
commit
9ef4a6d891
2 changed files with 25 additions and 11 deletions
|
@ -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
|
||||||
|
|
|
@ -1408,7 +1408,8 @@ mod test_uniq_solve {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn quicksort() {
|
fn quicksort() {
|
||||||
infer_eq(
|
with_larger_debug_stack(|| {
|
||||||
|
infer_eq(
|
||||||
indoc!(
|
indoc!(
|
||||||
r#"
|
r#"
|
||||||
quicksort : List (Num a), Int, Int -> List (Num a)
|
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)))))"
|
"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,18 +2330,17 @@ 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
|
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
|
findPath
|
||||||
"#
|
"#
|
||||||
|
@ -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(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue