mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Support '??' syntax for optional record fields
This commit is contained in:
parent
3d4dd5b583
commit
a24fe430b4
21 changed files with 42 additions and 43 deletions
|
@ -386,7 +386,7 @@ impl<'a> Nodify<'a> for AssignedField<'a, TypeAnnotation<'a>> {
|
|||
assigned_field_value_to_node(n.into_bump_str(), arena, sp, &value.value, ":", flags)
|
||||
}
|
||||
AssignedField::OptionalValue(name, sp, value) => {
|
||||
assigned_field_value_to_node(name.value, arena, sp, &value.value, "?", flags)
|
||||
assigned_field_value_to_node(name.value, arena, sp, &value.value, "??", flags)
|
||||
}
|
||||
AssignedField::LabelOnly(name) => NodeInfo {
|
||||
before: &[],
|
||||
|
@ -512,7 +512,7 @@ fn format_assigned_field_help<T>(
|
|||
|
||||
buf.spaces(separator_spaces);
|
||||
buf.indent(indent);
|
||||
buf.push('?');
|
||||
buf.push_str("??");
|
||||
buf.spaces(1);
|
||||
ann.value.format(buf, indent);
|
||||
}
|
||||
|
|
|
@ -701,16 +701,8 @@ fn fmt_apply(
|
|||
if !expr.before.is_empty() {
|
||||
format_spaces(buf, expr.before, Newlines::Yes, indent);
|
||||
}
|
||||
expr.item.format_with_options(
|
||||
buf,
|
||||
if use_commas_and_parens {
|
||||
Parens::NotNeeded
|
||||
} else {
|
||||
Parens::InApply
|
||||
},
|
||||
Newlines::Yes,
|
||||
indent,
|
||||
);
|
||||
expr.item
|
||||
.format_with_options(buf, Parens::InApply, Newlines::Yes, indent);
|
||||
|
||||
if use_commas_and_parens {
|
||||
buf.push('(');
|
||||
|
|
|
@ -268,7 +268,7 @@ fn fmt_pattern_only(
|
|||
Pattern::OptionalField(name, loc_pattern) => {
|
||||
buf.indent(indent);
|
||||
snakify_camel_ident(buf, name);
|
||||
buf.push_str(" ?");
|
||||
buf.push_str(" ??");
|
||||
buf.spaces(1);
|
||||
loc_pattern.format(buf, indent);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue