Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix dropping the wrong argument for List.map when it captures #6108

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion crates/compiler/mono/src/code_gen_help/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,25 @@ impl<'a> CallerProc<'a> {

let argument_layouts = match capture_layout {
None => passed_function.argument_layouts,
Some(_) => &passed_function.argument_layouts[1..],
Some(_capture_layout) => {
let capture_layout_index = passed_function.argument_layouts.len() - 1;

#[cfg(debug_assertions)]
{
let passed_capture_layout =
passed_function.argument_layouts[capture_layout_index];
let repr = layout_interner.get_repr(passed_capture_layout);

if let LayoutRepr::LambdaSet(lambda_set) = repr {
assert!(layout_interner
.equiv(_capture_layout, lambda_set.runtime_representation()));
} else {
panic!("unexpected layout for capture argument");
}
}

&passed_function.argument_layouts[..capture_layout_index]
}
};

let capture_symbol = ARG_SYMBOLS[0];
Expand Down