mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Combine ! and ? into single TrySuffix AST node
This commit is contained in:
parent
cc5bf3f164
commit
3bc5c1dc12
42 changed files with 859 additions and 162 deletions
|
@ -9,8 +9,7 @@ use crate::spaces::{
|
|||
use crate::Buf;
|
||||
use roc_module::called_via::{self, BinOp};
|
||||
use roc_parse::ast::{
|
||||
is_expr_suffixed, AssignedField, Base, Collection, CommentOrNewline, Expr, ExtractSpaces,
|
||||
OldRecordBuilderField, Pattern, WhenBranch,
|
||||
is_expr_suffixed, AssignedField, Base, Collection, CommentOrNewline, Expr, ExtractSpaces, OldRecordBuilderField, Pattern, TryTarget, WhenBranch
|
||||
};
|
||||
use roc_parse::ast::{StrLiteral, StrSegment};
|
||||
use roc_parse::ident::Accessor;
|
||||
|
@ -47,7 +46,7 @@ impl<'a> Formattable for Expr<'a> {
|
|||
| OpaqueRef(_)
|
||||
| Crash => false,
|
||||
|
||||
RecordAccess(inner, _) | TupleAccess(inner, _) | TaskAwaitBang(inner) => {
|
||||
RecordAccess(inner, _) | TupleAccess(inner, _) | TrySuffix { expr: inner, .. } => {
|
||||
inner.is_multiline()
|
||||
}
|
||||
|
||||
|
@ -520,9 +519,12 @@ impl<'a> Formattable for Expr<'a> {
|
|||
buf.push('.');
|
||||
buf.push_str(key);
|
||||
}
|
||||
TaskAwaitBang(expr) => {
|
||||
TrySuffix { expr, target } => {
|
||||
expr.format_with_options(buf, Parens::InApply, Newlines::Yes, indent);
|
||||
buf.push('!');
|
||||
match target {
|
||||
TryTarget::Task => buf.push('!'),
|
||||
TryTarget::Result => buf.push('?'),
|
||||
}
|
||||
}
|
||||
MalformedIdent(str, _) => {
|
||||
buf.indent(indent);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue