feat: rename error to fail
This commit is contained in:
parent
5318c94892
commit
1ab1ff9a1f
|
@ -116,7 +116,7 @@ fn str_to_keyword(word: &str) -> Option<Token> {
|
|||
"type" => Some(Token::Type),
|
||||
"trace" => Some(Token::Trace),
|
||||
"test" => Some(Token::Test),
|
||||
"error" => Some(Token::ErrorTerm),
|
||||
"error" => Some(Token::Fail),
|
||||
"validator" => Some(Token::Validator),
|
||||
_ => None,
|
||||
}
|
||||
|
|
|
@ -552,7 +552,7 @@ impl UntypedExpr {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn error(reason: Option<Self>, location: Span) -> Self {
|
||||
pub fn fail(reason: Option<Self>, location: Span) -> Self {
|
||||
UntypedExpr::Trace {
|
||||
location,
|
||||
kind: TraceKind::Error,
|
||||
|
|
|
@ -873,7 +873,7 @@ impl<'comments> Formatter<'comments> {
|
|||
) -> Document<'a> {
|
||||
let (keyword, default_text) = match kind {
|
||||
TraceKind::Trace => ("trace", None),
|
||||
TraceKind::Error => ("error", Some(DEFAULT_ERROR_STR.to_string())),
|
||||
TraceKind::Error => ("fail", Some(DEFAULT_ERROR_STR.to_string())),
|
||||
TraceKind::Todo => ("todo", Some(DEFAULT_TODO_STR.to_string())),
|
||||
};
|
||||
|
||||
|
|
|
@ -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}\"")
|
||||
|
|
|
@ -247,7 +247,7 @@ fn test_format_nested_function_calls() {
|
|||
,
|
||||
when output.datum is {
|
||||
InlineDatum(_) -> True
|
||||
_ -> error "expected inline datum"
|
||||
_ -> fail "expected inline datum"
|
||||
},
|
||||
]
|
||||
|> list.and
|
||||
|
@ -271,13 +271,13 @@ fn test_format_trace_todo_error() {
|
|||
fn foo_3() {
|
||||
when x is {
|
||||
Foo -> True
|
||||
_ -> error
|
||||
_ -> fail
|
||||
}
|
||||
}
|
||||
|
||||
fn foo_4() {
|
||||
if 14 == 42 {
|
||||
error "I don't think so"
|
||||
fail "I don't think so"
|
||||
} else {
|
||||
trace "been there"
|
||||
True
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/format.rs
|
||||
description: "Code:\n\nfn foo(output) {\n [\n output.address.stake_credential == Some(\n Inline(\n VerificationKeyCredential(\n #\"66666666666666666666666666666666666666666666666666666666\",\n ))\n )\n ,\n when output.datum is {\n InlineDatum(_) -> True\n _ -> error \"expected inline datum\"\n },\n ]\n |> list.and\n}\n"
|
||||
description: "Code:\n\nfn foo(output) {\n [\n output.address.stake_credential == Some(\n Inline(\n VerificationKeyCredential(\n #\"66666666666666666666666666666666666666666666666666666666\",\n ))\n )\n ,\n when output.datum is {\n InlineDatum(_) -> True\n _ -> fail \"expected inline datum\"\n },\n ]\n |> list.and\n}\n"
|
||||
---
|
||||
fn foo(output) {
|
||||
[
|
||||
|
@ -13,7 +13,7 @@ fn foo(output) {
|
|||
),
|
||||
when output.datum is {
|
||||
InlineDatum(_) -> True
|
||||
_ -> error @"expected inline datum"
|
||||
_ -> fail @"expected inline datum"
|
||||
},
|
||||
]
|
||||
|> list.and
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/format.rs
|
||||
description: "Code:\n\nfn foo_1() {\n todo\n}\n\nfn foo_2() {\n todo \"my custom message\"\n}\n\nfn foo_3() {\n when x is {\n Foo -> True\n _ -> error\n }\n}\n\nfn foo_4() {\n if 14 == 42 {\n error \"I don't think so\"\n } else {\n trace \"been there\"\n True\n }\n}\n"
|
||||
description: "Code:\n\nfn foo_1() {\n todo\n}\n\nfn foo_2() {\n todo \"my custom message\"\n}\n\nfn foo_3() {\n when x is {\n Foo -> True\n _ -> fail\n }\n}\n\nfn foo_4() {\n if 14 == 42 {\n fail \"I don't think so\"\n } else {\n trace \"been there\"\n True\n }\n}\n"
|
||||
---
|
||||
fn foo_1() {
|
||||
todo
|
||||
|
@ -13,13 +13,13 @@ fn foo_2() {
|
|||
fn foo_3() {
|
||||
when x is {
|
||||
Foo -> True
|
||||
_ -> error
|
||||
_ -> fail
|
||||
}
|
||||
}
|
||||
|
||||
fn foo_4() {
|
||||
if 14 == 42 {
|
||||
error @"I don't think so"
|
||||
fail @"I don't think so"
|
||||
} else {
|
||||
trace @"been there"
|
||||
True
|
||||
|
|
|
@ -2601,7 +2601,7 @@ fn when_bool_is_true() {
|
|||
True ->
|
||||
True
|
||||
False ->
|
||||
error
|
||||
fail
|
||||
}
|
||||
}
|
||||
"#;
|
||||
|
@ -2622,7 +2622,7 @@ fn when_bool_is_true_switched_cases() {
|
|||
test it() {
|
||||
when True is {
|
||||
False ->
|
||||
error
|
||||
fail
|
||||
True ->
|
||||
True
|
||||
}
|
||||
|
@ -2645,7 +2645,7 @@ fn when_bool_is_false() {
|
|||
test it() {
|
||||
when False is {
|
||||
False ->
|
||||
error
|
||||
fail
|
||||
True ->
|
||||
True
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue