mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
Merge branch 'main' into i4717
Signed-off-by: Ayaz <20735482+ayazhafiz@users.noreply.github.com>
This commit is contained in:
commit
b400851586
17 changed files with 232 additions and 28 deletions
|
@ -6968,10 +6968,18 @@ fn substitute_in_stmt_help<'a>(
|
|||
default_branch,
|
||||
ret_layout,
|
||||
} => {
|
||||
let opt_default = substitute_in_stmt_help(arena, default_branch.1, subs);
|
||||
|
||||
let mut did_change = false;
|
||||
|
||||
let cond_symbol = match substitute(subs, *cond_symbol) {
|
||||
Some(s) => {
|
||||
did_change = true;
|
||||
s
|
||||
}
|
||||
None => *cond_symbol,
|
||||
};
|
||||
|
||||
let opt_default = substitute_in_stmt_help(arena, default_branch.1, subs);
|
||||
|
||||
let opt_branches = Vec::from_iter_in(
|
||||
branches.iter().map(|(label, info, branch)| {
|
||||
match substitute_in_stmt_help(arena, branch, subs) {
|
||||
|
@ -7008,7 +7016,7 @@ fn substitute_in_stmt_help<'a>(
|
|||
};
|
||||
|
||||
Some(arena.alloc(Switch {
|
||||
cond_symbol: *cond_symbol,
|
||||
cond_symbol,
|
||||
cond_layout: *cond_layout,
|
||||
default_branch,
|
||||
branches,
|
||||
|
|
56
crates/compiler/test_mono/generated/issue_4557.txt
Normal file
56
crates/compiler/test_mono/generated/issue_4557.txt
Normal file
|
@ -0,0 +1,56 @@
|
|||
procedure Bool.11 (#Attr.2, #Attr.3):
|
||||
let Bool.24 : Int1 = lowlevel Eq #Attr.2 #Attr.3;
|
||||
ret Bool.24;
|
||||
|
||||
procedure Bool.4 (#Attr.2, #Attr.3):
|
||||
let Bool.23 : Int1 = lowlevel Or #Attr.2 #Attr.3;
|
||||
ret Bool.23;
|
||||
|
||||
procedure Test.1 (Test.2, Test.3):
|
||||
let Test.17 : {Int1, Int1} = Struct {Test.2, Test.3};
|
||||
let Test.34 : Int1 = StructAtIndex 0 Test.17;
|
||||
let Test.33 : Int1 = StructAtIndex 1 Test.17;
|
||||
let Test.19 : Int1 = CallByName Test.1 Test.33 Test.34;
|
||||
let Test.27 : {} = Struct {};
|
||||
joinpoint Test.28 Test.21:
|
||||
let Test.23 : {} = Struct {};
|
||||
joinpoint Test.24 Test.22:
|
||||
let Test.20 : Int1 = CallByName Bool.11 Test.21 Test.22;
|
||||
dec Test.22;
|
||||
dec Test.21;
|
||||
let Test.18 : Int1 = CallByName Bool.4 Test.19 Test.20;
|
||||
ret Test.18;
|
||||
in
|
||||
switch Test.33:
|
||||
case 0:
|
||||
let Test.25 : Str = CallByName Test.9 Test.23;
|
||||
jump Test.24 Test.25;
|
||||
|
||||
default:
|
||||
let Test.26 : Str = CallByName Test.11 Test.23;
|
||||
jump Test.24 Test.26;
|
||||
|
||||
in
|
||||
switch Test.34:
|
||||
case 0:
|
||||
let Test.29 : Str = CallByName Test.9 Test.27;
|
||||
jump Test.28 Test.29;
|
||||
|
||||
default:
|
||||
let Test.30 : Str = CallByName Test.11 Test.27;
|
||||
jump Test.28 Test.30;
|
||||
|
||||
|
||||
procedure Test.11 (Test.36):
|
||||
let Test.37 : Str = "a";
|
||||
ret Test.37;
|
||||
|
||||
procedure Test.9 (Test.39):
|
||||
let Test.40 : Str = "a";
|
||||
ret Test.40;
|
||||
|
||||
procedure Test.0 ():
|
||||
let Test.38 : Int1 = false;
|
||||
let Test.35 : Int1 = true;
|
||||
let Test.13 : Int1 = CallByName Test.1 Test.38 Test.35;
|
||||
ret Test.13;
|
|
@ -0,0 +1,35 @@
|
|||
procedure Bool.11 (#Attr.2, #Attr.3):
|
||||
let Bool.23 : Int1 = lowlevel Eq #Attr.2 #Attr.3;
|
||||
ret Bool.23;
|
||||
|
||||
procedure Str.3 (#Attr.2, #Attr.3):
|
||||
let Str.266 : Str = lowlevel StrConcat #Attr.2 #Attr.3;
|
||||
ret Str.266;
|
||||
|
||||
procedure Test.2 (Test.7):
|
||||
let Test.24 : Str = ".trace(\"";
|
||||
let Test.26 : Str = "\")";
|
||||
let Test.25 : Str = CallByName Str.3 Test.7 Test.26;
|
||||
dec Test.26;
|
||||
let Test.23 : Str = CallByName Str.3 Test.24 Test.25;
|
||||
dec Test.25;
|
||||
let Test.22 : [<r>C List *self, C Str] = TagId(1) Test.23;
|
||||
let Test.21 : List [<r>C List *self, C Str] = Array [Test.22];
|
||||
let Test.8 : [<r>C List *self, C Str] = TagId(0) Test.21;
|
||||
let Test.20 : List [<r>C List *self, C Str] = Array [Test.8];
|
||||
let Test.19 : [<r>C List *self, C Str] = TagId(0) Test.20;
|
||||
ret Test.19;
|
||||
|
||||
procedure Test.3 ():
|
||||
let Test.18 : Str = "interface_header";
|
||||
let Test.17 : [<r>C List *self, C Str] = CallByName Test.2 Test.18;
|
||||
ret Test.17;
|
||||
|
||||
procedure Test.0 ():
|
||||
let Test.14 : [<r>C List *self, C Str] = CallByName Test.3;
|
||||
let Test.16 : Str = "";
|
||||
let Test.15 : [<r>C List *self, C Str] = TagId(1) Test.16;
|
||||
let Test.13 : Int1 = CallByName Bool.11 Test.14 Test.15;
|
||||
dec Test.15;
|
||||
dec Test.14;
|
||||
ret Test.13;
|
|
@ -1925,6 +1925,28 @@ fn encode_derived_tag_one_field_string() {
|
|||
)
|
||||
}
|
||||
|
||||
#[mono_test(no_check)]
|
||||
fn polymorphic_expression_unification() {
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
RenderTree : [
|
||||
Text Str,
|
||||
Indent (List RenderTree),
|
||||
]
|
||||
parseFunction : Str -> RenderTree
|
||||
parseFunction = \name ->
|
||||
last = Indent [Text ".trace(\"\(name)\")" ]
|
||||
Indent [last]
|
||||
|
||||
values = parseFunction "interface_header"
|
||||
|
||||
main = values == Text ""
|
||||
"#
|
||||
)
|
||||
}
|
||||
|
||||
#[mono_test]
|
||||
fn encode_derived_tag_two_payloads_string() {
|
||||
indoc!(
|
||||
|
@ -2264,3 +2286,17 @@ fn list_map_take_capturing_or_noncapturing() {
|
|||
"###
|
||||
)
|
||||
}
|
||||
|
||||
#[mono_test]
|
||||
fn issue_4557() {
|
||||
indoc!(
|
||||
r###"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
isEqQ = \q1, q2 -> when T q1 q2 is
|
||||
T (U f1) (U f2) -> Bool.or (isEqQ (U f2) (U f1)) (f1 {} == f2 {})
|
||||
|
||||
main = isEqQ (U \{} -> "a") (U \{} -> "a")
|
||||
"###
|
||||
)
|
||||
}
|
||||
|
|
|
@ -3967,6 +3967,8 @@ fn flat_type_to_err_type(
|
|||
ErrorType::Record(err_fields, TypeExt::RigidOpen(var))
|
||||
}
|
||||
|
||||
ErrorType::Error => ErrorType::Record(err_fields, TypeExt::Closed),
|
||||
|
||||
other =>
|
||||
panic!("Tried to convert a record extension to an error, but the record extension had the ErrorType of {:?}", other)
|
||||
}
|
||||
|
@ -3991,6 +3993,8 @@ fn flat_type_to_err_type(
|
|||
ErrorType::TagUnion(err_tags, TypeExt::RigidOpen(var), pol)
|
||||
}
|
||||
|
||||
ErrorType::Error => ErrorType::TagUnion(err_tags, TypeExt::Closed, pol),
|
||||
|
||||
other =>
|
||||
panic!("Tried to convert a tag union extension to an error, but the tag union extension had the ErrorType of {:?}", other)
|
||||
}
|
||||
|
@ -4019,6 +4023,8 @@ fn flat_type_to_err_type(
|
|||
ErrorType::TagUnion(err_tags, TypeExt::RigidOpen(var), pol)
|
||||
}
|
||||
|
||||
ErrorType::Error => ErrorType::TagUnion(err_tags, TypeExt::Closed, pol),
|
||||
|
||||
other =>
|
||||
panic!("Tried to convert a tag union extension to an error, but the tag union extension had the ErrorType of {:?}", other)
|
||||
}
|
||||
|
@ -4049,6 +4055,8 @@ fn flat_type_to_err_type(
|
|||
ErrorType::RecursiveTagUnion(rec_error_type, err_tags, TypeExt::RigidOpen(var), pol)
|
||||
}
|
||||
|
||||
ErrorType::Error => ErrorType::RecursiveTagUnion(rec_error_type, err_tags, TypeExt::Closed, pol),
|
||||
|
||||
other =>
|
||||
panic!("Tried to convert a recursive tag union extension to an error, but the tag union extension had the ErrorType of {:?}", other)
|
||||
}
|
||||
|
|
|
@ -2979,7 +2979,18 @@ fn unify_flat_type<M: MetaCollector>(
|
|||
let mut outcome = unify_zip_slices(env, pool, *l_args, *r_args, ctx.mode);
|
||||
|
||||
if outcome.mismatches.is_empty() {
|
||||
outcome.union(merge(env, ctx, Structure(Apply(*r_symbol, *r_args))));
|
||||
let chosen_args = SubsSlice::reserve_into_subs(env.subs, l_args.len());
|
||||
for ((store, var1), var2) in chosen_args
|
||||
.into_iter()
|
||||
.zip(l_args.into_iter())
|
||||
.zip(r_args.into_iter())
|
||||
{
|
||||
let var1 = env.subs[var1];
|
||||
let var2 = env.subs[var2];
|
||||
env.subs[store] = choose_merged_var(env.subs, var1, var2);
|
||||
}
|
||||
|
||||
outcome.union(merge(env, ctx, Structure(Apply(*r_symbol, chosen_args))));
|
||||
}
|
||||
|
||||
outcome
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue