mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
single element record pattern
This commit is contained in:
parent
a94f597e1e
commit
2ceb50bd02
1 changed files with 21 additions and 25 deletions
|
@ -5631,7 +5631,11 @@ fn store_pattern_help<'a>(
|
|||
| StrLiteral(_) => {
|
||||
return StorePattern::NotProductive(stmt);
|
||||
}
|
||||
NewtypeDestructure { arguments, .. } => {
|
||||
NewtypeDestructure { arguments, .. } => match arguments.as_slice() {
|
||||
[single] => {
|
||||
return store_pattern_help(env, procs, layout_cache, &single.0, outer_symbol, stmt);
|
||||
}
|
||||
_ => {
|
||||
let mut fields = Vec::with_capacity_in(arguments.len(), env.arena);
|
||||
fields.extend(arguments.iter().map(|x| x.1));
|
||||
|
||||
|
@ -5650,6 +5654,7 @@ fn store_pattern_help<'a>(
|
|||
stmt,
|
||||
);
|
||||
}
|
||||
},
|
||||
AppliedTag {
|
||||
arguments,
|
||||
layout,
|
||||
|
@ -5798,23 +5803,14 @@ fn store_newtype_pattern<'a>(
|
|||
) -> StorePattern<'a> {
|
||||
use Pattern::*;
|
||||
|
||||
let write_tag = false;
|
||||
|
||||
let mut arg_layouts = Vec::with_capacity_in(arguments.len(), env.arena);
|
||||
let mut is_productive = false;
|
||||
|
||||
if write_tag {
|
||||
// add an element for the tag discriminant
|
||||
arg_layouts.push(Layout::Builtin(TAG_SIZE));
|
||||
}
|
||||
|
||||
for (_, layout) in arguments {
|
||||
arg_layouts.push(*layout);
|
||||
}
|
||||
|
||||
for (index, (argument, arg_layout)) in arguments.iter().enumerate().rev() {
|
||||
let index = if write_tag { index + 1 } else { index };
|
||||
|
||||
let mut arg_layout = *arg_layout;
|
||||
|
||||
if let Layout::RecursivePointer = arg_layout {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue