mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +00:00
Don't pass empty captures
This commit is contained in:
parent
13c45151a4
commit
fcb907b0c9
3 changed files with 13 additions and 9 deletions
|
@ -5287,9 +5287,13 @@ pub fn with_hole<'a>(
|
||||||
unreachable!("a closure syntactically always must have at least one argument")
|
unreachable!("a closure syntactically always must have at least one argument")
|
||||||
}
|
}
|
||||||
RawFunctionLayout::ErasedFunction(argument_layouts, ret_layout) => {
|
RawFunctionLayout::ErasedFunction(argument_layouts, ret_layout) => {
|
||||||
let captured_symbols = Vec::from_iter_in(captured_symbols, env.arena);
|
let captured_symbols = if captured_symbols.is_empty() {
|
||||||
let captured_symbols = captured_symbols.into_bump_slice();
|
CapturedSymbols::None
|
||||||
let captured_symbols = CapturedSymbols::Captured(captured_symbols);
|
} else {
|
||||||
|
let captured_symbols = Vec::from_iter_in(captured_symbols, env.arena);
|
||||||
|
let captured_symbols = captured_symbols.into_bump_slice();
|
||||||
|
CapturedSymbols::Captured(captured_symbols)
|
||||||
|
};
|
||||||
let resolved_erased_lambda = ResolvedErasedLambda::new(
|
let resolved_erased_lambda = ResolvedErasedLambda::new(
|
||||||
env,
|
env,
|
||||||
layout_cache,
|
layout_cache,
|
||||||
|
|
|
@ -368,11 +368,13 @@ pub fn build_erased_function<'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
struct ResolvedErasedCaptures<'a> {
|
struct ResolvedErasedCaptures<'a> {
|
||||||
layouts: &'a [InLayout<'a>],
|
layouts: &'a [InLayout<'a>],
|
||||||
symbols: &'a [Symbol],
|
symbols: &'a [Symbol],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct ResolvedErasedLambda<'a> {
|
pub struct ResolvedErasedLambda<'a> {
|
||||||
captures: Option<ResolvedErasedCaptures<'a>>,
|
captures: Option<ResolvedErasedCaptures<'a>>,
|
||||||
lambda_name: LambdaName<'a>,
|
lambda_name: LambdaName<'a>,
|
||||||
|
|
|
@ -21,10 +21,8 @@ procedure Test.1 (Test.2):
|
||||||
let Test.34 : Int1 = CallByName Bool.2;
|
let Test.34 : Int1 = CallByName Bool.2;
|
||||||
if Test.34 then
|
if Test.34 then
|
||||||
dec Test.2;
|
dec Test.2;
|
||||||
let Test.40 : {} = Struct {};
|
let Test.38 : FunPtr(({}) -> Str) = FunctionPointer Test.3;
|
||||||
let Test.38 : Boxed({}) = Box Test.40;
|
let Test.35 : ?Erased = ErasedMake { value: <null>, callee: Test.38 };
|
||||||
let Test.39 : FunPtr(({}, ?Erased) -> Str) = FunctionPointer Test.3;
|
|
||||||
let Test.35 : ?Erased = ErasedMake { value: Test.38, callee: Test.39 };
|
|
||||||
ret Test.35;
|
ret Test.35;
|
||||||
else
|
else
|
||||||
let Test.33 : {Str} = Struct {Test.2};
|
let Test.33 : {Str} = Struct {Test.2};
|
||||||
|
@ -56,8 +54,8 @@ procedure Test.4 (Test.27, #Attr.12):
|
||||||
procedure Test.0 ():
|
procedure Test.0 ():
|
||||||
let Test.6 : {} = Struct {};
|
let Test.6 : {} = Struct {};
|
||||||
let Test.16 : Str = "";
|
let Test.16 : Str = "";
|
||||||
let Test.41 : FunPtr((Str) -> ?Erased) = FunctionPointer Test.1;
|
let Test.39 : FunPtr((Str) -> ?Erased) = FunctionPointer Test.1;
|
||||||
let Test.17 : ?Erased = ErasedMake { value: <null>, callee: Test.41 };
|
let Test.17 : ?Erased = ErasedMake { value: <null>, callee: Test.39 };
|
||||||
joinpoint Test.18 Test.7:
|
joinpoint Test.18 Test.7:
|
||||||
joinpoint Test.8 Test.5:
|
joinpoint Test.8 Test.5:
|
||||||
ret Test.5;
|
ret Test.5;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue