mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-21 07:49:17 +03:00
Chase recursive layouts as appropriate
This commit is contained in:
parent
673ca9a02f
commit
3382be6cb9
@ -1406,7 +1406,7 @@ fn path_to_expr_help<'a>(
|
||||
PathInstruction::TagIndex { index, tag_id } => {
|
||||
let index = *index;
|
||||
|
||||
match layout_interner.get(layout) {
|
||||
match layout_interner.chase_recursive(layout) {
|
||||
Layout::Union(union_layout) => {
|
||||
let inner_expr = Expr::UnionAtIndex {
|
||||
tag_id: *tag_id,
|
||||
@ -1506,7 +1506,7 @@ fn test_to_comparison<'a>(
|
||||
// (e.g. record pattern guard matches)
|
||||
debug_assert!(union.alternatives.len() > 1);
|
||||
|
||||
match layout_interner.get(test_layout) {
|
||||
match layout_interner.chase_recursive(test_layout) {
|
||||
Layout::Union(union_layout) => {
|
||||
let lhs = Expr::Literal(Literal::Int((tag_id as i128).to_ne_bytes()));
|
||||
|
||||
@ -2108,7 +2108,7 @@ fn decide_to_branching<'a>(
|
||||
|
||||
// We have learned more about the exact layout of the cond (based on the path)
|
||||
// but tests are still relative to the original cond symbol
|
||||
let inner_cond_layout_raw = layout_cache.get_in(inner_cond_layout);
|
||||
let inner_cond_layout_raw = layout_cache.interner.chase_recursive(inner_cond_layout);
|
||||
let mut switch = if let Layout::Union(union_layout) = inner_cond_layout_raw {
|
||||
let tag_id_symbol = env.unique_symbol();
|
||||
|
||||
|
@ -5927,7 +5927,7 @@ fn convert_tag_union<'a>(
|
||||
layout_cache.from_var(env.arena, variant_var, env.subs),
|
||||
"Wrapped"
|
||||
);
|
||||
let union_layout = match layout_cache.get_in(variant_layout) {
|
||||
let union_layout = match layout_cache.interner.chase_recursive(variant_layout) {
|
||||
Layout::Union(ul) => ul,
|
||||
other => internal_error!(
|
||||
"unexpected layout {:?} for {:?}",
|
||||
@ -9466,10 +9466,11 @@ fn from_can_pattern_help<'a>(
|
||||
// problems down the line because we hash layouts and an unrolled
|
||||
// version is not the same as the minimal version.
|
||||
let whole_var_layout = layout_cache.from_var(env.arena, *whole_var, env.subs);
|
||||
let layout = match whole_var_layout.map(|l| layout_cache.get_in(l)) {
|
||||
Ok(Layout::Union(ul)) => ul,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let layout =
|
||||
match whole_var_layout.map(|l| layout_cache.interner.chase_recursive(l)) {
|
||||
Ok(Layout::Union(ul)) => ul,
|
||||
_ => internal_error!(),
|
||||
};
|
||||
|
||||
use WrappedVariant::*;
|
||||
match variant {
|
||||
|
@ -615,7 +615,7 @@ fn function_r_branch_body<'a, 'i>(
|
||||
scrutinee,
|
||||
layout,
|
||||
tag_id,
|
||||
} => match env.interner.get(*layout) {
|
||||
} => match env.interner.chase_recursive(*layout) {
|
||||
Layout::Union(UnionLayout::NonRecursive(_)) => temp,
|
||||
Layout::Union(union_layout) if !union_layout.tag_is_null(*tag_id) => {
|
||||
let ctor_info = CtorInfo {
|
||||
|
Loading…
Reference in New Issue
Block a user