mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 16:21:11 +00:00
fix some uniqueness problems
This commit is contained in:
parent
4c34312871
commit
81bfea53e2
1 changed files with 44 additions and 38 deletions
|
@ -166,8 +166,8 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
|
||||
// addWrap : Int, Int -> Int
|
||||
add_type(Symbol::NUM_ADD_WRAP, {
|
||||
let_tvars! { u, v, w };
|
||||
unique_function(vec![int_type(u), int_type(v)], int_type(w))
|
||||
let_tvars! { u, v, w, int };
|
||||
unique_function(vec![int_type(u, int), int_type(v, int)], int_type(w, int))
|
||||
});
|
||||
|
||||
// sub or (-) : Num a, Num a -> Num a
|
||||
|
@ -199,8 +199,8 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
|
||||
// mulWrap : Int, Int -> Int
|
||||
add_type(Symbol::NUM_MUL_WRAP, {
|
||||
let_tvars! { u, v, w };
|
||||
unique_function(vec![int_type(u), int_type(v)], int_type(w))
|
||||
let_tvars! { u, v, w , int };
|
||||
unique_function(vec![int_type(u, int), int_type(v, int)], int_type(w, int))
|
||||
});
|
||||
|
||||
// mulChecked : Num a, Num a -> Result (Num a) [ Overflow ]*
|
||||
|
@ -257,38 +257,41 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
|
||||
// rem : Attr * Int, Attr * Int -> Attr * (Result (Attr * Int) (Attr * [ DivByZero ]*))
|
||||
add_type(Symbol::NUM_REM, {
|
||||
let_tvars! { star1, star2, star3, star4, star5 };
|
||||
let_tvars! { star1, star2, star3, star4, star5, int };
|
||||
unique_function(
|
||||
vec![int_type(star1), int_type(star2)],
|
||||
result_type(star3, int_type(star4), lift(star5, div_by_zero())),
|
||||
vec![int_type(star1, int), int_type(star2, int)],
|
||||
result_type(star3, int_type(star4, int), lift(star5, div_by_zero())),
|
||||
)
|
||||
});
|
||||
|
||||
// maxInt : Int
|
||||
add_type(Symbol::NUM_MAX_INT, {
|
||||
let_tvars! { star };
|
||||
int_type(star)
|
||||
let_tvars! { star, int };
|
||||
int_type(star, int)
|
||||
});
|
||||
|
||||
// minInt : Int
|
||||
add_type(Symbol::NUM_MIN_INT, {
|
||||
let_tvars! { star };
|
||||
int_type(star)
|
||||
let_tvars! { star, int };
|
||||
int_type(star, int)
|
||||
});
|
||||
|
||||
// divFloor or (//) : Int, Int -> Result Int [ DivByZero ]*
|
||||
add_type(Symbol::NUM_DIV_INT, {
|
||||
let_tvars! { star1, star2, star3, star4, star5 };
|
||||
let_tvars! { star1, star2, star3, star4, star5, int };
|
||||
unique_function(
|
||||
vec![int_type(star1), int_type(star2)],
|
||||
result_type(star3, int_type(star4), lift(star5, div_by_zero())),
|
||||
vec![int_type(star1, int), int_type(star2, int)],
|
||||
result_type(star3, int_type(star4, int), lift(star5, div_by_zero())),
|
||||
)
|
||||
});
|
||||
|
||||
// bitwiseAnd : Attr * Int, Attr * Int -> Attr * Int
|
||||
add_type(Symbol::NUM_BITWISE_AND, {
|
||||
let_tvars! { star1, star2, star3 };
|
||||
unique_function(vec![int_type(star1), int_type(star2)], int_type(star3))
|
||||
let_tvars! { star1, star2, star3, int };
|
||||
unique_function(
|
||||
vec![int_type(star1, int), int_type(star2, int)],
|
||||
int_type(star3, int),
|
||||
)
|
||||
});
|
||||
|
||||
// divFloat : Float, Float -> Float
|
||||
|
@ -302,8 +305,8 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
|
||||
// round : Float -> Int
|
||||
add_type(Symbol::NUM_ROUND, {
|
||||
let_tvars! { star1, star2 };
|
||||
unique_function(vec![float_type(star1)], int_type(star2))
|
||||
let_tvars! { star1, star2, int };
|
||||
unique_function(vec![float_type(star1)], int_type(star2, int))
|
||||
});
|
||||
|
||||
// sqrt : Float -> Float
|
||||
|
@ -391,20 +394,23 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
|
||||
// ceiling : Float -> Int
|
||||
add_type(Symbol::NUM_CEILING, {
|
||||
let_tvars! { star1, star2 };
|
||||
unique_function(vec![float_type(star1)], int_type(star2))
|
||||
let_tvars! { star1, star2, int };
|
||||
unique_function(vec![float_type(star1)], int_type(star2, int))
|
||||
});
|
||||
|
||||
// powInt : Int, Int -> Int
|
||||
add_type(Symbol::NUM_POW_INT, {
|
||||
let_tvars! { star1, star2, star3 };
|
||||
unique_function(vec![int_type(star1), int_type(star2)], int_type(star3))
|
||||
let_tvars! { star1, star2, star3 , int };
|
||||
unique_function(
|
||||
vec![int_type(star1, int), int_type(star2, int)],
|
||||
int_type(star3, int),
|
||||
)
|
||||
});
|
||||
|
||||
// floor : Float -> Int
|
||||
add_type(Symbol::NUM_FLOOR, {
|
||||
let_tvars! { star1, star2 };
|
||||
unique_function(vec![float_type(star1)], int_type(star2))
|
||||
let_tvars! { star1, star2 , int};
|
||||
unique_function(vec![float_type(star1)], int_type(star2, int))
|
||||
});
|
||||
|
||||
// atan : Float -> Float
|
||||
|
@ -479,8 +485,8 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
|
||||
// len : Attr * (List *) -> Attr * Int
|
||||
add_type(Symbol::LIST_LEN, {
|
||||
let_tvars! { star1, a, star2 };
|
||||
unique_function(vec![list_type(star1, a)], int_type(star2))
|
||||
let_tvars! { star1, a, star2 , int };
|
||||
unique_function(vec![list_type(star1, a)], int_type(star2, int))
|
||||
});
|
||||
|
||||
fn list_was_empty() -> SolvedType {
|
||||
|
@ -536,7 +542,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
);
|
||||
|
||||
add_type(Symbol::LIST_GET, {
|
||||
let_tvars! { a, u, star1, star2, star3, star4 };
|
||||
let_tvars! { a, u, star1, star2, star3, star4, int};
|
||||
|
||||
unique_function(
|
||||
vec![
|
||||
|
@ -547,7 +553,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
SolvedType::Apply(Symbol::LIST_LIST, vec![attr_type(u, a)]),
|
||||
],
|
||||
),
|
||||
int_type(star2),
|
||||
int_type(star2, int),
|
||||
],
|
||||
result_type(star3, attr_type(u, a), lift(star4, index_out_of_bounds)),
|
||||
)
|
||||
|
@ -559,7 +565,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
// Attr (u | v) a
|
||||
// -> Attr * (List (Attr u a))
|
||||
add_type(Symbol::LIST_SET, {
|
||||
let_tvars! { u, v, w, star1, star2, a };
|
||||
let_tvars! { u, v, w, star1, star2, a, int};
|
||||
|
||||
unique_function(
|
||||
vec![
|
||||
|
@ -570,7 +576,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
SolvedType::Apply(Symbol::LIST_LIST, vec![attr_type(u, a)]),
|
||||
],
|
||||
),
|
||||
int_type(star1),
|
||||
int_type(star1, int),
|
||||
SolvedType::Apply(Symbol::ATTR_ATTR, vec![container(u, vec![v]), flex(a)]),
|
||||
],
|
||||
SolvedType::Apply(
|
||||
|
@ -627,10 +633,10 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
// , Attr Shared a
|
||||
// -> Attr * (List (Attr Shared a))
|
||||
add_type(Symbol::LIST_REPEAT, {
|
||||
let_tvars! { a, star1, star2 };
|
||||
let_tvars! { a, star1, star2, int };
|
||||
|
||||
unique_function(
|
||||
vec![int_type(star1), shared(flex(a))],
|
||||
vec![int_type(star1, int), shared(flex(a))],
|
||||
SolvedType::Apply(
|
||||
Symbol::ATTR_ATTR,
|
||||
vec![
|
||||
|
@ -1162,14 +1168,14 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
|
||||
// Str.countGraphemes : Attr * Str, -> Attr * Int
|
||||
add_type(Symbol::STR_COUNT_GRAPHEMES, {
|
||||
let_tvars! { star1, star2 };
|
||||
unique_function(vec![str_type(star1)], int_type(star2))
|
||||
let_tvars! { star1, star2, int };
|
||||
unique_function(vec![str_type(star1)], int_type(star2, int))
|
||||
});
|
||||
|
||||
// fromInt : Attr * Int -> Attr * Str
|
||||
add_type(Symbol::STR_FROM_INT, {
|
||||
let_tvars! { star1, star2 };
|
||||
unique_function(vec![int_type(star1)], str_type(star2))
|
||||
let_tvars! { star1, star2, int };
|
||||
unique_function(vec![int_type(star1, int)], str_type(star2))
|
||||
});
|
||||
|
||||
// Result module
|
||||
|
@ -1261,8 +1267,8 @@ fn float_type(u: VarId) -> SolvedType {
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn int_type(u: VarId) -> SolvedType {
|
||||
let inner_type = lift(u, flex(u));
|
||||
fn int_type(u: VarId, range: VarId) -> SolvedType {
|
||||
let inner_type = lift(u, flex(range));
|
||||
let integer = builtin_aliases::integer_type(inner_type.clone());
|
||||
let attr_fb = lift(u, integer);
|
||||
let num = builtin_aliases::num_type(attr_fb);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue