Load non-function derived ability specializations correctly

This commit is contained in:
Ayaz Hafiz 2022-08-03 16:10:44 -05:00
parent de3a12167b
commit 8b63402b1c
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
2 changed files with 20 additions and 5 deletions

View file

@ -5078,7 +5078,7 @@ fn load_derived_partial_procs<'a>(
// TODO: we can be even lazier here if we move `add_def_to_module` to happen in mono. Also, the
// timings would be more accurate.
for (derived_symbol, derived_expr) in derives_to_add.into_iter() {
for (derived_symbol, (derived_expr, derived_expr_var)) in derives_to_add.into_iter() {
let mut mono_env = roc_mono::ir::Env {
arena,
subs,
@ -5117,7 +5117,22 @@ fn load_derived_partial_procs<'a>(
return_type,
)
}
_ => internal_error!("Expected only functions to be derived"),
_ => {
// mark this symbols as a top-level thunk before any other work on the procs
new_module_thunks.push(derived_symbol);
PartialProc {
annotation: derived_expr_var,
// This is a 0-arity thunk, so it has no arguments.
pattern_symbols: &[],
// This is a top-level definition, so it cannot capture anything
captured_symbols: CapturedSymbols::None,
body: derived_expr,
body_var: derived_expr_var,
// This is a 0-arity thunk, so it cannot be recursive
is_self_recursive: false,
}
}
};
procs_base