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:
microproofs
2023-08-06 18:49:50 -04:00
committed by Kasey
parent 624fdee9ea
commit 1d9878c5ee
5 changed files with 115 additions and 26 deletions

View File

@@ -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 }
}
}

View File

@@ -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),
};

View File

@@ -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",
},
}

View File

@@ -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",
},
},
},
],