Merge pull request #4869 from roc-lang/josh-recursive-union-bug-2

Skip nullable ID in nullable wrapped tags when iterating
This commit is contained in:
Ayaz 2023-01-10 12:05:42 -06:00 committed by GitHub
commit 73020ca696
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 88 additions and 7 deletions

View file

@ -9798,21 +9798,20 @@ fn from_can_pattern_help<'a>(
}
NullableWrapped {
sorted_tag_layouts: ref tags,
sorted_tag_layouts: ref non_nulled_tags,
nullable_id,
nullable_name,
} => {
debug_assert!(!tags.is_empty());
for (i, (tag_name, args)) in tags.iter().enumerate() {
if i == nullable_id as usize {
debug_assert!(args.is_empty());
for id in 0..(non_nulled_tags.len() + 1) {
if id == nullable_id as usize {
ctors.push(Ctor {
tag_id: TagId(i as _),
tag_id: TagId(id as _),
name: CtorName::Tag(nullable_name.expect_tag_ref().clone()),
arity: 0,
});
} else {
let i = if id < nullable_id.into() { id } else { id - 1 };
let (tag_name, args) = &non_nulled_tags[i];
ctors.push(Ctor {
tag_id: TagId(i as _),
name: CtorName::Tag(tag_name.expect_tag_ref().clone()),