mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
store is_recursive info for unwrapped tags
This commit is contained in:
parent
5ba378551c
commit
a1231058da
3 changed files with 30 additions and 16 deletions
|
@ -2713,8 +2713,6 @@ macro_rules! match_on_closure_argument {
|
|||
|
||||
let arena = $env.arena;
|
||||
|
||||
let function_layout = arena.alloc(top_level).full();
|
||||
|
||||
let arg_layouts = top_level.arguments;
|
||||
let ret_layout = top_level.result;
|
||||
|
||||
|
@ -2735,7 +2733,6 @@ macro_rules! match_on_closure_argument {
|
|||
},
|
||||
arguments: arena.alloc([$($x,)* top_level_function, closure_data]),
|
||||
},
|
||||
function_layout,
|
||||
$layout,
|
||||
$assigned,
|
||||
$hole,
|
||||
|
@ -4276,7 +4273,10 @@ fn convert_tag_union<'a>(
|
|||
)
|
||||
}
|
||||
|
||||
Unwrapped(_, field_layouts) => {
|
||||
Unwrapped {
|
||||
arguments: field_layouts,
|
||||
..
|
||||
} => {
|
||||
let field_symbols_temp = sorted_field_symbols(env, procs, layout_cache, args);
|
||||
|
||||
let mut field_symbols = Vec::with_capacity_in(field_layouts.len(), env.arena);
|
||||
|
@ -7014,7 +7014,10 @@ fn from_can_pattern_help<'a>(
|
|||
union,
|
||||
}
|
||||
}
|
||||
Unwrapped(_, field_layouts) => {
|
||||
Unwrapped {
|
||||
arguments: field_layouts,
|
||||
..
|
||||
} => {
|
||||
let union = crate::exhaustive::Union {
|
||||
render_as: RenderAs::Tag,
|
||||
alternatives: vec![Ctor {
|
||||
|
@ -7709,7 +7712,6 @@ fn lowlevel_match_on_lambda_set<'a, ToLowLevelCall>(
|
|||
lambda_set: LambdaSet<'a>,
|
||||
closure_data_symbol: Symbol,
|
||||
to_lowlevel_call: ToLowLevelCall,
|
||||
function_layout: Layout<'a>,
|
||||
return_layout: Layout<'a>,
|
||||
assigned: Symbol,
|
||||
hole: &'a Stmt<'a>,
|
||||
|
@ -7729,7 +7731,6 @@ where
|
|||
closure_data_symbol,
|
||||
lambda_set.is_represented(),
|
||||
to_lowlevel_call,
|
||||
function_layout,
|
||||
return_layout,
|
||||
assigned,
|
||||
hole,
|
||||
|
@ -7774,7 +7775,6 @@ where
|
|||
closure_data_symbol,
|
||||
lambda_set.is_represented(),
|
||||
to_lowlevel_call,
|
||||
function_layout,
|
||||
return_layout,
|
||||
assigned,
|
||||
hole,
|
||||
|
@ -7791,7 +7791,6 @@ where
|
|||
closure_data_symbol,
|
||||
lambda_set.is_represented(),
|
||||
to_lowlevel_call,
|
||||
function_layout,
|
||||
return_layout,
|
||||
assigned,
|
||||
hole,
|
||||
|
@ -7810,7 +7809,6 @@ fn lowlevel_union_lambda_set_to_switch<'a, ToLowLevelCall>(
|
|||
closure_data_symbol: Symbol,
|
||||
closure_env_layout: Option<Layout<'a>>,
|
||||
to_lowlevel_call: ToLowLevelCall,
|
||||
function_layout: Layout<'a>,
|
||||
return_layout: Layout<'a>,
|
||||
assigned: Symbol,
|
||||
hole: &'a Stmt<'a>,
|
||||
|
@ -8236,7 +8234,6 @@ fn lowlevel_enum_lambda_set_to_switch<'a, ToLowLevelCall>(
|
|||
closure_data_symbol: Symbol,
|
||||
closure_env_layout: Option<Layout<'a>>,
|
||||
to_lowlevel_call: ToLowLevelCall,
|
||||
function_layout: Layout<'a>,
|
||||
return_layout: Layout<'a>,
|
||||
assigned: Symbol,
|
||||
hole: &'a Stmt<'a>,
|
||||
|
|
|
@ -289,7 +289,9 @@ impl<'a> LambdaSet<'a> {
|
|||
Unit | UnitWithArguments => Layout::Struct(&[]),
|
||||
BoolUnion { .. } => Layout::Builtin(Builtin::Int1),
|
||||
ByteUnion(_) => Layout::Builtin(Builtin::Int8),
|
||||
Unwrapped(_tag_name, layouts) => Layout::Struct(layouts.into_bump_slice()),
|
||||
Unwrapped {
|
||||
arguments: layouts, ..
|
||||
} => Layout::Struct(layouts.into_bump_slice()),
|
||||
Wrapped(variant) => {
|
||||
use WrappedVariant::*;
|
||||
|
||||
|
@ -1274,9 +1276,16 @@ pub enum UnionVariant<'a> {
|
|||
Never,
|
||||
Unit,
|
||||
UnitWithArguments,
|
||||
BoolUnion { ttrue: TagName, ffalse: TagName },
|
||||
BoolUnion {
|
||||
ttrue: TagName,
|
||||
ffalse: TagName,
|
||||
},
|
||||
ByteUnion(Vec<'a, TagName>),
|
||||
Unwrapped(TagName, Vec<'a, Layout<'a>>),
|
||||
Unwrapped {
|
||||
tag_name: TagName,
|
||||
arguments: Vec<'a, Layout<'a>>,
|
||||
is_recursive: bool,
|
||||
},
|
||||
Wrapped(WrappedVariant<'a>),
|
||||
}
|
||||
|
||||
|
@ -1494,7 +1503,11 @@ pub fn union_sorted_tags_help<'a>(
|
|||
fields: layouts.into_bump_slice(),
|
||||
})
|
||||
} else {
|
||||
UnionVariant::Unwrapped(tag_name, layouts)
|
||||
UnionVariant::Unwrapped {
|
||||
tag_name,
|
||||
arguments: layouts,
|
||||
is_recursive: opt_rec_var.is_some(),
|
||||
}
|
||||
}
|
||||
}
|
||||
num_tags => {
|
||||
|
@ -1646,7 +1659,10 @@ pub fn layout_from_tag_union<'a>(
|
|||
Unit | UnitWithArguments => Layout::Struct(&[]),
|
||||
BoolUnion { .. } => Layout::Builtin(Builtin::Int1),
|
||||
ByteUnion(_) => Layout::Builtin(Builtin::Int8),
|
||||
Unwrapped(_, mut field_layouts) => {
|
||||
Unwrapped {
|
||||
arguments: mut field_layouts,
|
||||
..
|
||||
} => {
|
||||
if field_layouts.len() == 1 {
|
||||
field_layouts.pop().unwrap()
|
||||
} else {
|
||||
|
|
|
@ -1997,6 +1997,7 @@ fn case_or_pattern() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn rosetree_basic() {
|
||||
assert_non_opt_evals_to!(
|
||||
indoc!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue