mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-22 08:17:40 +03:00
special-case rose tree field access
This commit is contained in:
parent
a1231058da
commit
11ed2cbcf8
@ -1438,6 +1438,12 @@ pub fn build_exp_expr<'a, 'ctx, 'env>(
|
||||
structure,
|
||||
wrapped: Wrapped::RecordOrSingleTagUnion,
|
||||
..
|
||||
}
|
||||
| AccessAtIndex {
|
||||
index,
|
||||
structure,
|
||||
wrapped: Wrapped::LikeARoseTree,
|
||||
..
|
||||
} => {
|
||||
// extract field from a record
|
||||
match load_symbol_and_layout(scope, structure) {
|
||||
|
@ -880,6 +880,10 @@ fn expr_spec(
|
||||
Wrapped::RecordOrSingleTagUnion => {
|
||||
builder.add_get_tuple_field(block, value_id, *index as u32)
|
||||
}
|
||||
Wrapped::LikeARoseTree => {
|
||||
let result_type = layout_spec(builder, layout)?;
|
||||
builder.add_unknown_with(block, &[value_id], result_type)
|
||||
}
|
||||
Wrapped::MultiTagUnion => {
|
||||
// Clearly this is not generally correct, but it should be for our examples
|
||||
let hacky_is_recursive =
|
||||
|
@ -597,7 +597,7 @@ fn to_relevant_branch_help<'a>(
|
||||
start.extend(end);
|
||||
}
|
||||
}
|
||||
Wrapped::RecordOrSingleTagUnion => {
|
||||
Wrapped::RecordOrSingleTagUnion | Wrapped::LikeARoseTree => {
|
||||
let sub_positions = arguments.into_iter().enumerate().map(
|
||||
|(index, (pattern, _))| {
|
||||
let mut new_path = path.to_vec();
|
||||
|
@ -1014,6 +1014,8 @@ pub enum Wrapped {
|
||||
EmptyRecord,
|
||||
SingleElementRecord,
|
||||
RecordOrSingleTagUnion,
|
||||
/// Like a rose tree; recursive, but only one tag
|
||||
LikeARoseTree,
|
||||
MultiTagUnion,
|
||||
}
|
||||
|
||||
@ -1046,7 +1048,7 @@ impl Wrapped {
|
||||
},
|
||||
_ => Some(Wrapped::MultiTagUnion),
|
||||
},
|
||||
NonNullableUnwrapped(_) => Some(Wrapped::RecordOrSingleTagUnion),
|
||||
NonNullableUnwrapped(_) => Some(Wrapped::LikeARoseTree),
|
||||
|
||||
NullableWrapped { .. } | NullableUnwrapped { .. } => {
|
||||
Some(Wrapped::MultiTagUnion)
|
||||
|
@ -1997,7 +1997,6 @@ fn case_or_pattern() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn rosetree_basic() {
|
||||
assert_non_opt_evals_to!(
|
||||
indoc!(
|
||||
|
Loading…
Reference in New Issue
Block a user