only expand recursive tag unions if it's a different type (think linked-list of trees)

This commit is contained in:
Folkert 2021-07-14 00:48:10 +02:00
parent 7701596469
commit 1bea704272
2 changed files with 7 additions and 2 deletions

View file

@ -19,7 +19,7 @@ use roc_types::subs::{Content, FlatType, Subs, Variable};
use std::collections::HashMap; use std::collections::HashMap;
use ven_pretty::{BoxAllocator, DocAllocator, DocBuilder}; use ven_pretty::{BoxAllocator, DocAllocator, DocBuilder};
pub const PRETTY_PRINT_IR_SYMBOLS: bool = true; pub const PRETTY_PRINT_IR_SYMBOLS: bool = false;
macro_rules! return_on_layout_error { macro_rules! return_on_layout_error {
($env:expr, $layout_result:expr) => { ($env:expr, $layout_result:expr) => {

View file

@ -1665,7 +1665,12 @@ pub fn union_sorted_tags_help<'a>(
has_any_arguments = true; has_any_arguments = true;
// make sure to not unroll recursive types! // make sure to not unroll recursive types!
if opt_rec_var.is_some() && is_recursive_tag_union(&layout) { let self_recursion = opt_rec_var.is_some()
&& subs.get_root_key_without_compacting(var)
== subs.get_root_key_without_compacting(opt_rec_var.unwrap())
&& is_recursive_tag_union(&layout);
if self_recursion {
arg_layouts.push(Layout::RecursivePointer); arg_layouts.push(Layout::RecursivePointer);
} else { } else {
arg_layouts.push(layout); arg_layouts.push(layout);