mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
Marks specializations for closure defs
This commit is contained in:
parent
7afcdf0f95
commit
b4f5e62f46
2 changed files with 30 additions and 17 deletions
|
@ -4353,25 +4353,39 @@ pub fn with_hole<'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Value(function_symbol) => match full_layout {
|
Value(function_symbol) => {
|
||||||
RawFunctionLayout::Function(arg_layouts, lambda_set, ret_layout) => {
|
let function_symbol = reuse_symbol_or_specialize(
|
||||||
let closure_data_symbol = function_symbol;
|
env,
|
||||||
|
procs,
|
||||||
|
layout_cache,
|
||||||
|
function_symbol,
|
||||||
|
fn_var,
|
||||||
|
);
|
||||||
|
|
||||||
result = match_on_lambda_set(
|
match full_layout {
|
||||||
env,
|
RawFunctionLayout::Function(
|
||||||
lambda_set,
|
|
||||||
closure_data_symbol,
|
|
||||||
arg_symbols,
|
|
||||||
arg_layouts,
|
arg_layouts,
|
||||||
|
lambda_set,
|
||||||
ret_layout,
|
ret_layout,
|
||||||
assigned,
|
) => {
|
||||||
hole,
|
let closure_data_symbol = function_symbol;
|
||||||
);
|
|
||||||
|
result = match_on_lambda_set(
|
||||||
|
env,
|
||||||
|
lambda_set,
|
||||||
|
closure_data_symbol,
|
||||||
|
arg_symbols,
|
||||||
|
arg_layouts,
|
||||||
|
ret_layout,
|
||||||
|
assigned,
|
||||||
|
hole,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
RawFunctionLayout::ZeroArgumentThunk(_) => {
|
||||||
|
unreachable!("calling a non-closure layout")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
RawFunctionLayout::ZeroArgumentThunk(_) => {
|
}
|
||||||
unreachable!("calling a non-closure layout")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
UnspecializedExpr(symbol) => {
|
UnspecializedExpr(symbol) => {
|
||||||
match procs.ability_member_aliases.get(symbol).unwrap() {
|
match procs.ability_member_aliases.get(symbol).unwrap() {
|
||||||
&AbilityMember(member) => {
|
&AbilityMember(member) => {
|
||||||
|
@ -5521,7 +5535,6 @@ pub fn from_can<'a>(
|
||||||
}
|
}
|
||||||
LetNonRec(def, cont, outer_annotation) => {
|
LetNonRec(def, cont, outer_annotation) => {
|
||||||
if let roc_can::pattern::Pattern::Identifier(symbol) = &def.loc_pattern.value {
|
if let roc_can::pattern::Pattern::Identifier(symbol) = &def.loc_pattern.value {
|
||||||
// dbg!(symbol, &def.loc_expr.value);
|
|
||||||
match def.loc_expr.value {
|
match def.loc_expr.value {
|
||||||
roc_can::expr::Expr::Closure(closure_data) => {
|
roc_can::expr::Expr::Closure(closure_data) => {
|
||||||
register_capturing_closure(env, procs, layout_cache, *symbol, closure_data);
|
register_capturing_closure(env, procs, layout_cache, *symbol, closure_data);
|
||||||
|
|
|
@ -3421,7 +3421,6 @@ fn polymorphic_def_used_in_closure() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm"))]
|
#[cfg(any(feature = "gen-llvm"))]
|
||||||
#[ignore = "This still doesn't work... yet"]
|
|
||||||
fn polymorphic_lambda_set_usage() {
|
fn polymorphic_lambda_set_usage() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
|
@ -3429,6 +3428,7 @@ fn polymorphic_lambda_set_usage() {
|
||||||
id1 = \x -> x
|
id1 = \x -> x
|
||||||
id2 = \y -> y
|
id2 = \y -> y
|
||||||
id = if True then id1 else id2
|
id = if True then id1 else id2
|
||||||
|
|
||||||
id 9u8
|
id 9u8
|
||||||
"#
|
"#
|
||||||
),
|
),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue