Skip nullable ID in nullable wrapped tags when iterating

This commit is contained in:
Ayaz Hafiz 2023-01-09 11:54:51 -06:00
parent ab7de647e4
commit b2688dd3b1
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
3 changed files with 59 additions and 7 deletions

View file

@ -9797,21 +9797,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()),