correct alignment in records!

This commit is contained in:
Folkert 2020-11-24 21:28:53 +01:00
parent 517f8f4a4a
commit 1e4f0e8b07
4 changed files with 42 additions and 26 deletions

View file

@ -412,7 +412,7 @@ fn test_at_path<'a>(selected_path: &Path, branch: &Branch<'a>, all_tests: &mut V
arguments.push((Pattern::Underscore, destruct.layout.clone()));
}
DestructType::Optional(_expr) => {
arguments.push((Pattern::Underscore, destruct.layout.clone()));
// do nothing
}
}
}
@ -540,23 +540,27 @@ fn to_relevant_branch_help<'a>(
..
} => {
debug_assert!(test_name == &TagName::Global(RECORD_TAG_NAME.into()));
let sub_positions = destructs.into_iter().enumerate().map(|(index, destruct)| {
let pattern = match destruct.typ {
DestructType::Guard(guard) => guard.clone(),
DestructType::Required => Pattern::Underscore,
DestructType::Optional(_expr) => Pattern::Underscore,
};
let sub_positions = destructs
.into_iter()
.filter(|destruct| !matches!(destruct.typ, DestructType::Optional(_)))
.enumerate()
.map(|(index, destruct)| {
let pattern = match destruct.typ {
DestructType::Guard(guard) => guard.clone(),
DestructType::Required => Pattern::Underscore,
DestructType::Optional(_expr) => unreachable!("because of the filter"),
};
(
Path::Index {
index: index as u64,
tag_id: *tag_id,
path: Box::new(path.clone()),
},
Guard::NoGuard,
pattern,
)
});
(
Path::Index {
index: index as u64,
tag_id: *tag_id,
path: Box::new(path.clone()),
},
Guard::NoGuard,
pattern,
)
});
start.extend(sub_positions);
start.extend(end);