mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
Merge branch 'trunk' into dict-more
This commit is contained in:
commit
fe98229aa3
19 changed files with 691 additions and 193 deletions
|
@ -735,10 +735,25 @@ pub fn build_exp_call<'a, 'ctx, 'env>(
|
|||
arg_vals.push(load_symbol(scope, arg));
|
||||
}
|
||||
|
||||
let call = match sub_expr {
|
||||
BasicValueEnum::PointerValue(ptr) => {
|
||||
let call = match (full_layout, sub_expr) {
|
||||
(_, BasicValueEnum::PointerValue(ptr)) => {
|
||||
env.builder.build_call(ptr, arg_vals.as_slice(), "tmp")
|
||||
}
|
||||
(Layout::Closure(_, _, _), BasicValueEnum::StructValue(closure_struct)) => {
|
||||
let fpointer = env
|
||||
.builder
|
||||
.build_extract_value(closure_struct, 0, "fpointer")
|
||||
.unwrap()
|
||||
.into_pointer_value();
|
||||
|
||||
let closure_data = env
|
||||
.builder
|
||||
.build_extract_value(closure_struct, 1, "closure_data")
|
||||
.unwrap();
|
||||
|
||||
arg_vals.push(closure_data);
|
||||
env.builder.build_call(fpointer, arg_vals.as_slice(), "tmp")
|
||||
}
|
||||
non_ptr => {
|
||||
panic!(
|
||||
"Tried to call by pointer, but encountered a non-pointer: {:?} {:?} {:?}",
|
||||
|
|
|
@ -1952,7 +1952,7 @@ mod gen_primitives {
|
|||
main =
|
||||
x : Tree F64
|
||||
x = singleton 3
|
||||
when x is
|
||||
when x is
|
||||
Tree 3.0 _ -> True
|
||||
_ -> False
|
||||
"#
|
||||
|
@ -2215,4 +2215,23 @@ mod gen_primitives {
|
|||
i64
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn build_then_apply_closure() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [ main ] to "./platform"
|
||||
|
||||
main : Str
|
||||
main =
|
||||
x = "long string that is malloced"
|
||||
|
||||
(\_ -> x) {}
|
||||
"#
|
||||
),
|
||||
"long string that is malloced",
|
||||
&'static str
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue