feat: rename error to fail
This commit is contained in:
@@ -17,9 +17,9 @@ pub fn parser(
|
||||
just(Token::Todo)
|
||||
.ignore_then(message().or_not())
|
||||
.map_with_span(UntypedExpr::todo),
|
||||
just(Token::ErrorTerm)
|
||||
just(Token::Fail)
|
||||
.ignore_then(message().or_not())
|
||||
.map_with_span(UntypedExpr::error),
|
||||
.map_with_span(UntypedExpr::fail),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ mod tests {
|
||||
fn error_basic() {
|
||||
assert_expr!(
|
||||
r#"
|
||||
error @"foo"
|
||||
fail @"foo"
|
||||
"#
|
||||
);
|
||||
}
|
||||
@@ -40,7 +40,7 @@ mod tests {
|
||||
fn error_sugar() {
|
||||
assert_expr!(
|
||||
r#"
|
||||
error "foo"
|
||||
fail "foo"
|
||||
"#
|
||||
);
|
||||
}
|
||||
@@ -7,7 +7,7 @@ pub mod assignment;
|
||||
mod block;
|
||||
pub(crate) mod bytearray;
|
||||
mod chained;
|
||||
mod error_todo;
|
||||
mod fail_todo;
|
||||
mod if_else;
|
||||
mod int;
|
||||
mod list;
|
||||
@@ -23,7 +23,7 @@ pub use anonymous_function::parser as anonymous_function;
|
||||
pub use block::parser as block;
|
||||
pub use bytearray::parser as bytearray;
|
||||
pub use chained::parser as chained;
|
||||
pub use error_todo::parser as error_todo;
|
||||
pub use fail_todo::parser as fail_todo;
|
||||
pub use if_else::parser as if_else;
|
||||
pub use int::parser as int;
|
||||
pub use list::parser as list;
|
||||
@@ -43,7 +43,7 @@ pub fn parser(
|
||||
) -> impl Parser<Token, UntypedExpr, Error = ParseError> + '_ {
|
||||
recursive(|expression| {
|
||||
choice((
|
||||
error_todo(sequence.clone()),
|
||||
fail_todo(sequence.clone()),
|
||||
pure_expression(sequence, expression),
|
||||
))
|
||||
})
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
---
|
||||
source: crates/aiken-lang/src/parser/expr/error_todo.rs
|
||||
description: "Code:\n\nerror @\"foo\"\n"
|
||||
source: crates/aiken-lang/src/parser/expr/fail_todo.rs
|
||||
description: "Code:\n\nfail @\"foo\"\n"
|
||||
---
|
||||
Trace {
|
||||
kind: Error,
|
||||
location: 0..12,
|
||||
location: 0..11,
|
||||
then: ErrorTerm {
|
||||
location: 0..12,
|
||||
location: 0..11,
|
||||
},
|
||||
text: String {
|
||||
location: 6..12,
|
||||
location: 5..11,
|
||||
value: "foo",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
---
|
||||
source: crates/aiken-lang/src/parser/expr/error_todo.rs
|
||||
description: "Code:\n\nerror \"foo\"\n"
|
||||
source: crates/aiken-lang/src/parser/expr/fail_todo.rs
|
||||
description: "Code:\n\nfail \"foo\"\n"
|
||||
---
|
||||
Trace {
|
||||
kind: Error,
|
||||
location: 0..11,
|
||||
location: 0..10,
|
||||
then: ErrorTerm {
|
||||
location: 0..11,
|
||||
location: 0..10,
|
||||
},
|
||||
text: String {
|
||||
location: 6..11,
|
||||
location: 5..10,
|
||||
value: "foo",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ mod tests {
|
||||
assert_expr!(
|
||||
r#"
|
||||
when val is {
|
||||
Bar1{..} -> error
|
||||
Bar1{..} -> fail
|
||||
}
|
||||
"#
|
||||
);
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
---
|
||||
source: crates/aiken-lang/src/parser/expr/when/clause.rs
|
||||
description: "Code:\n\nwhen val is {\n Bar1{..} -> error\n}\n"
|
||||
description: "Code:\n\nwhen val is {\n Bar1{..} -> fail\n}\n"
|
||||
---
|
||||
When {
|
||||
location: 0..35,
|
||||
location: 0..34,
|
||||
subject: Var {
|
||||
location: 5..8,
|
||||
name: "val",
|
||||
},
|
||||
clauses: [
|
||||
UntypedClause {
|
||||
location: 16..33,
|
||||
location: 16..32,
|
||||
patterns: [
|
||||
Constructor {
|
||||
is_record: true,
|
||||
@@ -26,12 +26,12 @@ When {
|
||||
guard: None,
|
||||
then: Trace {
|
||||
kind: Error,
|
||||
location: 28..33,
|
||||
location: 28..32,
|
||||
then: ErrorTerm {
|
||||
location: 28..33,
|
||||
location: 28..32,
|
||||
},
|
||||
text: String {
|
||||
location: 28..33,
|
||||
location: 28..32,
|
||||
value: "aiken::error",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -222,7 +222,9 @@ pub fn lexer() -> impl Parser<char, Vec<(Token, Span)>, Error = ParseError> {
|
||||
|
||||
let keyword = text::ident().map(|s: String| match s.as_str() {
|
||||
"trace" => Token::Trace,
|
||||
"error" => Token::ErrorTerm,
|
||||
"fail" => Token::Fail,
|
||||
// TODO: delete this eventually
|
||||
"error" => Token::Fail,
|
||||
"as" => Token::As,
|
||||
"assert" => Token::Expect,
|
||||
"expect" => Token::Expect,
|
||||
|
||||
@@ -74,7 +74,7 @@ pub enum Token {
|
||||
Fn,
|
||||
If,
|
||||
Else,
|
||||
ErrorTerm,
|
||||
Fail,
|
||||
Expect,
|
||||
Is,
|
||||
Let,
|
||||
@@ -170,7 +170,7 @@ impl fmt::Display for Token {
|
||||
Token::Trace => "trace",
|
||||
Token::Type => "type",
|
||||
Token::Test => "test",
|
||||
Token::ErrorTerm => "error",
|
||||
Token::Fail => "fail",
|
||||
Token::Validator => "validator",
|
||||
};
|
||||
write!(f, "\"{s}\"")
|
||||
|
||||
Reference in New Issue
Block a user