Unable function marks for symbol specializations

This commit is contained in:
Ayaz Hafiz 2022-05-06 12:03:35 -04:00
parent e0bfe6c762
commit 9e35cf9060
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
2 changed files with 34 additions and 17 deletions

View file

@ -799,11 +799,6 @@ impl<'a> SymbolSpecializations<'a> {
let arena = env.arena; let arena = env.arena;
let subs: &Subs = env.subs; let subs: &Subs = env.subs;
// let is_closure = matches!(
// subs.get_content_without_compacting(specialization_var),
// Content::Structure(FlatType::Func(..))
// );
let layout = match layout_cache.from_var(arena, specialization_var, subs) { let layout = match layout_cache.from_var(arena, specialization_var, subs) {
Ok(layout) => layout, Ok(layout) => layout,
// This can happen when the def symbol has a type error. In such cases just use the // This can happen when the def symbol has a type error. In such cases just use the
@ -811,21 +806,25 @@ impl<'a> SymbolSpecializations<'a> {
Err(_) => return symbol, Err(_) => return symbol,
}; };
// let function_mark = if is_closure { let is_closure = matches!(
// let fn_layout = match layout_cache.raw_from_var(arena, specialization_var, subs) { subs.get_content_without_compacting(specialization_var),
// Ok(layout) => layout, Content::Structure(FlatType::Func(..))
// // This can happen when the def symbol has a type error. In such cases just use the );
// // def symbol, which is erroring. let function_mark = if is_closure {
// Err(_) => return symbol, let fn_layout = match layout_cache.raw_from_var(arena, specialization_var, subs) {
// }; Ok(layout) => layout,
// Some(fn_layout) // This can happen when the def symbol has a type error. In such cases just use the
// } else { // def symbol, which is erroring.
// None Err(_) => return symbol,
// }; };
Some(fn_layout)
} else {
None
};
let specialization_mark = SpecializationMark { let specialization_mark = SpecializationMark {
layout, layout,
function_mark: None, function_mark,
}; };
let symbol_specializations = self.0.get_or_insert(symbol, || Default::default()); let symbol_specializations = self.0.get_or_insert(symbol, || Default::default());

View file

@ -3436,3 +3436,21 @@ fn polymorphic_lambda_set_usage() {
u8 u8
) )
} }
#[test]
#[cfg(any(feature = "gen-llvm"))]
fn polymorphic_lambda_set_multiple_specializations() {
assert_evals_to!(
indoc!(
r#"
id1 = \x -> x
id2 = \y -> y
id = if True then id1 else id2
(id 9u8) + Num.toU8 (id 16u16)
"#
),
25,
u8
)
}