mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Implement printing of nullable wrapped IR layouts
This commit is contained in:
parent
58930cc96c
commit
d59b137f45
1 changed files with 26 additions and 1 deletions
|
@ -805,7 +805,32 @@ impl<'a> UnionLayout<'a> {
|
|||
.append(tags_doc)
|
||||
.append(alloc.text("]"))
|
||||
}
|
||||
_ => alloc.text("TODO"),
|
||||
NullableWrapped {
|
||||
nullable_id,
|
||||
other_tags,
|
||||
} => {
|
||||
let nullable_id = nullable_id as usize;
|
||||
let tags_docs = (0..(other_tags.len() + 1)).map(|i| {
|
||||
if i == nullable_id {
|
||||
alloc.text("<null>")
|
||||
} else {
|
||||
let idx = if i > nullable_id { i - 1 } else { i };
|
||||
alloc.text("C ").append(
|
||||
alloc.intersperse(
|
||||
other_tags[idx]
|
||||
.iter()
|
||||
.map(|x| x.to_doc(alloc, interner, Parens::InTypeParam)),
|
||||
" ",
|
||||
),
|
||||
)
|
||||
}
|
||||
});
|
||||
let tags_docs = alloc.intersperse(tags_docs, alloc.text(", "));
|
||||
alloc
|
||||
.text("[<rnw>")
|
||||
.append(tags_docs)
|
||||
.append(alloc.text("]"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue