fix: code gen tests now up to date using trace
fix: Formatter should take ErrorTerm and return "fail" fix: fail with no reason should just return ErrorTerm
This commit is contained in:
@@ -553,14 +553,15 @@ impl UntypedExpr {
|
||||
}
|
||||
|
||||
pub fn fail(reason: Option<Self>, location: Span) -> Self {
|
||||
UntypedExpr::Trace {
|
||||
location,
|
||||
kind: TraceKind::Error,
|
||||
then: Box::new(UntypedExpr::ErrorTerm { location }),
|
||||
text: Box::new(reason.unwrap_or_else(|| UntypedExpr::String {
|
||||
if let Some(reason) = reason {
|
||||
UntypedExpr::Trace {
|
||||
location,
|
||||
value: DEFAULT_ERROR_STR.to_string(),
|
||||
})),
|
||||
kind: TraceKind::Error,
|
||||
then: Box::new(UntypedExpr::ErrorTerm { location }),
|
||||
text: Box::new(reason),
|
||||
}
|
||||
} else {
|
||||
UntypedExpr::ErrorTerm { location }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -860,7 +860,7 @@ impl<'comments> Formatter<'comments> {
|
||||
.append(suffix)
|
||||
}
|
||||
|
||||
UntypedExpr::ErrorTerm { .. } => "error".to_doc(),
|
||||
UntypedExpr::ErrorTerm { .. } => "fail".to_doc(),
|
||||
|
||||
UntypedExpr::TraceIfFalse { value, .. } => self.trace_if_false(value),
|
||||
};
|
||||
|
||||
@@ -2,14 +2,6 @@
|
||||
source: crates/aiken-lang/src/parser/expr/fail_todo_trace.rs
|
||||
description: "Code:\n\nfail\n"
|
||||
---
|
||||
Trace {
|
||||
kind: Error,
|
||||
ErrorTerm {
|
||||
location: 0..4,
|
||||
then: ErrorTerm {
|
||||
location: 0..4,
|
||||
},
|
||||
text: String {
|
||||
location: 0..4,
|
||||
value: "aiken::error",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -24,16 +24,8 @@ When {
|
||||
},
|
||||
],
|
||||
guard: None,
|
||||
then: Trace {
|
||||
kind: Error,
|
||||
then: ErrorTerm {
|
||||
location: 28..32,
|
||||
then: ErrorTerm {
|
||||
location: 28..32,
|
||||
},
|
||||
text: String {
|
||||
location: 28..32,
|
||||
value: "aiken::error",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user