Merge branch 'main' into fromutf-roc

This commit is contained in:
shua 2025-01-20 19:16:38 +01:00
commit 6c29d7aa1f
No known key found for this signature in database
237 changed files with 7237 additions and 5353 deletions

View file

@ -2095,13 +2095,13 @@ mod eq {
LyingEq := U8 implements [Eq {is_eq}]
is_eq = \@LyingEq m, @LyingEq n -> m != n
is_eq = \@LyingEq(m), @LyingEq(n) -> m != n
main =
a = @LyingEq 10
b = @LyingEq 5
c = @LyingEq 5
if Bool.is_eq a b && !(Bool.is_eq b c) then
a = @LyingEq(10)
b = @LyingEq(5)
c = @LyingEq(5)
if Bool.is_eq(a, b) and !(Bool.is_eq(b, c)) then
"okay"
else
"fail"

View file

@ -121,7 +121,7 @@ fn bool_logic() {
bool2 = Bool.false
bool3 = !bool1
(bool1 && bool2) || bool2 && bool3
(bool1 and bool2) or bool2 and bool3
"#
),
false,
@ -132,19 +132,19 @@ fn bool_logic() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn and_bool() {
assert_evals_to!("Bool.true && Bool.true", true, bool);
assert_evals_to!("Bool.true && Bool.false", false, bool);
assert_evals_to!("Bool.false && Bool.true", false, bool);
assert_evals_to!("Bool.false && Bool.false", false, bool);
assert_evals_to!("Bool.true and Bool.true", true, bool);
assert_evals_to!("Bool.true and Bool.false", false, bool);
assert_evals_to!("Bool.false and Bool.true", false, bool);
assert_evals_to!("Bool.false and Bool.false", false, bool);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn or_bool() {
assert_evals_to!("Bool.true || Bool.true", true, bool);
assert_evals_to!("Bool.true || Bool.false", true, bool);
assert_evals_to!("Bool.false || Bool.true", true, bool);
assert_evals_to!("Bool.false || Bool.false", false, bool);
assert_evals_to!("Bool.true or Bool.true", true, bool);
assert_evals_to!("Bool.true or Bool.false", true, bool);
assert_evals_to!("Bool.false or Bool.true", true, bool);
assert_evals_to!("Bool.false or Bool.false", false, bool);
}
#[test]
@ -544,7 +544,7 @@ fn eq_different_rosetrees() {
cd = c2 == d2
ab && cd
ab and cd
"#
),
true,

View file

@ -662,7 +662,7 @@ fn linked_list_len_1() {
LinkedList a : [Nil, Cons a (LinkedList a)]
one : LinkedList (Int *)
one : LinkedList (Int _)
one = Cons 1 Nil
length : LinkedList a -> Int *
@ -690,7 +690,7 @@ fn linked_list_len_twice_1() {
LinkedList a : [Nil, Cons a (LinkedList a)]
one : LinkedList (Int *)
one : LinkedList (Int _)
one = Cons 1 Nil
length : LinkedList a -> Int *
@ -718,7 +718,7 @@ fn linked_list_len_3() {
LinkedList a : [Nil, Cons a (LinkedList a)]
three : LinkedList (Int *)
three : LinkedList (Int _)
three = Cons 3 (Cons 2 (Cons 1 Nil))
length : LinkedList a -> Int *
@ -747,7 +747,7 @@ fn linked_list_sum_num_a() {
LinkedList a : [Nil, Cons a (LinkedList a)]
three : LinkedList (Int *)
three : LinkedList (Int _)
three = Cons 3 (Cons 2 (Cons 1 Nil))
@ -776,7 +776,7 @@ fn linked_list_sum_int() {
LinkedList a : [Nil, Cons a (LinkedList a)]
zero : LinkedList (Int *)
zero : LinkedList (Int _)
zero = Nil
sum : LinkedList (Int a) -> Int a
@ -804,7 +804,7 @@ fn linked_list_map() {
LinkedList a : [Nil, Cons a (LinkedList a)]
three : LinkedList (Int *)
three : LinkedList (Int _)
three = Cons 3 (Cons 2 (Cons 1 Nil))
sum : LinkedList (Num a) -> Num a
@ -836,7 +836,7 @@ fn when_nested_maybe() {
r"
Maybe a : [Nothing, Just a]
x : Maybe (Maybe (Int a))
x : Maybe (Maybe (Int _))
x = Just (Just 41)
when x is
@ -853,7 +853,7 @@ fn when_nested_maybe() {
r"
Maybe a : [Nothing, Just a]
x : Maybe (Maybe (Int *))
x : Maybe (Maybe (Int _))
x = Just Nothing
when x is
@ -871,7 +871,7 @@ fn when_nested_maybe() {
r"
Maybe a : [Nothing, Just a]
x : Maybe (Maybe (Int *))
x : Maybe (Maybe (Int _))
x = Nothing
when x is
@ -1402,7 +1402,7 @@ fn recursive_function_with_rigid() {
else
1 + foo { count: state.count - 1, x: state.x }
main : Int *
main : Int _
main =
foo { count: 3, x: {} }
"#
@ -1517,7 +1517,7 @@ fn rbtree_balance_3() {
balance = \key, left ->
Node key left Empty
main : RedBlackTree (Int *)
main : RedBlackTree (Int _)
main =
balance 0 Empty
"#
@ -1696,7 +1696,7 @@ fn nested_pattern_match_two_ways() {
_ -> 3
_ -> 3
main : Int *
main : Int _
main =
when balance Nil is
_ -> 3
@ -1719,7 +1719,7 @@ fn nested_pattern_match_two_ways() {
Cons 1 (Cons 1 _) -> 3
_ -> 3
main : Int *
main : Int _
main =
when balance Nil is
_ -> 3
@ -1751,7 +1751,7 @@ fn linked_list_guarded_double_pattern_match() {
_ -> 3
_ -> 3
main : Int *
main : Int _
main =
when balance Nil is
_ -> 3
@ -1778,7 +1778,7 @@ fn linked_list_double_pattern_match() {
Cons _ (Cons x _) -> x
_ -> 0
main : Int *
main : Int _
main =
foo (Cons 1 (Cons 32 Nil))
"#
@ -1886,7 +1886,7 @@ fn wildcard_rigid() {
@Effect inner
main : MyTask {} (Frac *)
main : MyTask {} (Frac _)
main = always {}
"#
),

View file

@ -135,7 +135,7 @@ fn err_type_var_annotation() {
assert_evals_to!(
indoc!(
r"
ok : Result I64 *
ok : Result I64 _
ok = Ok 3
Result.map_ok ok (\x -> x + 1)

View file

@ -2218,3 +2218,29 @@ fn str_drop_suffix() {
RocStr
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
fn with_ascii_lowercased() {
assert_evals_to!(
r#"
Str.with_ascii_lowercased("cOFFÉ")
"#,
RocStr::from("coffÉ"),
RocStr
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
fn with_ascii_lowercased_non_zero_refcount() {
assert_evals_to!(
r#"
original = "cOFFÉ cOFFÉ cOFFÉ cOFFÉ cOFFÉ cOFFÉ cOFFÉ cOFFÉ cOFFÉ cOFFÉ cOFFÉ cOFFÉ"
res = Str.with_ascii_lowercased(original)
Str.drop_prefix(res, original)
"#,
RocStr::from("coffÉ coffÉ coffÉ coffÉ coffÉ coffÉ coffÉ coffÉ coffÉ coffÉ coffÉ coffÉ"),
RocStr
);
}

View file

@ -158,19 +158,19 @@ fn even_odd() {
assert_evals_to!(
indoc!(
r"
even = \n ->
even = |n|
when n is
0 -> Bool.true
1 -> Bool.false
_ -> odd (n - 1)
_ -> odd(n - 1)
odd = \n ->
odd = |n|
when n is
0 -> Bool.false
1 -> Bool.true
_ -> even (n - 1)
_ -> even(n - 1)
odd 5 && even 42
odd(5) and even(42)
"
),
true,
@ -1075,7 +1075,7 @@ fn applied_tag_function_result() {
assert_evals_to!(
indoc!(
r#"
x : List (Result Str *)
x : List (Result Str _)
x = List.map ["a", "b"] Ok
List.keep_oks x (\y -> y)
@ -2315,12 +2315,12 @@ fn recursive_tag_id_in_allocation_eq() {
]
x : Value
x = G 42
x = G(42)
y : Value
y = H 42
y = H(42)
main = (x == x) && (x != y) && (y == y)
main = x == x and x != y and y == y
"#
),
true,

View file

@ -66,7 +66,7 @@ fn build_app_mono<'a>(
let or1_expr = Expr::Call(Call {
call_type: CallType::LowLevel {
op: LowLevel::Or,
op: LowLevel::NumBitwiseOr,
update_mode: UpdateModeId::BACKEND_DUMMY,
},
arguments: arena.alloc([js_call_result, host_call_result]),
@ -74,7 +74,7 @@ fn build_app_mono<'a>(
let or2_expr = Expr::Call(Call {
call_type: CallType::LowLevel {
op: LowLevel::Or,
op: LowLevel::NumBitwiseOr,
update_mode: UpdateModeId::BACKEND_DUMMY,
},
arguments: arena.alloc([or1, bitflag]),