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), |         "type" => Some(Token::Type), | ||||||
|         "trace" => Some(Token::Trace), |         "trace" => Some(Token::Trace), | ||||||
|         "test" => Some(Token::Test), |         "test" => Some(Token::Test), | ||||||
|         "error" => Some(Token::ErrorTerm), |         "error" => Some(Token::Fail), | ||||||
|         "validator" => Some(Token::Validator), |         "validator" => Some(Token::Validator), | ||||||
|         _ => None, |         _ => 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 { |         UntypedExpr::Trace { | ||||||
|             location, |             location, | ||||||
|             kind: TraceKind::Error, |             kind: TraceKind::Error, | ||||||
|  |  | ||||||
|  | @ -873,7 +873,7 @@ impl<'comments> Formatter<'comments> { | ||||||
|     ) -> Document<'a> { |     ) -> Document<'a> { | ||||||
|         let (keyword, default_text) = match kind { |         let (keyword, default_text) = match kind { | ||||||
|             TraceKind::Trace => ("trace", None), |             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())), |             TraceKind::Todo => ("todo", Some(DEFAULT_TODO_STR.to_string())), | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -17,9 +17,9 @@ pub fn parser( | ||||||
|         just(Token::Todo) |         just(Token::Todo) | ||||||
|             .ignore_then(message().or_not()) |             .ignore_then(message().or_not()) | ||||||
|             .map_with_span(UntypedExpr::todo), |             .map_with_span(UntypedExpr::todo), | ||||||
|         just(Token::ErrorTerm) |         just(Token::Fail) | ||||||
|             .ignore_then(message().or_not()) |             .ignore_then(message().or_not()) | ||||||
|             .map_with_span(UntypedExpr::error), |             .map_with_span(UntypedExpr::fail), | ||||||
|     )) |     )) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -31,7 +31,7 @@ mod tests { | ||||||
|     fn error_basic() { |     fn error_basic() { | ||||||
|         assert_expr!( |         assert_expr!( | ||||||
|             r#" |             r#" | ||||||
|             error @"foo" |             fail @"foo" | ||||||
|             "#
 |             "#
 | ||||||
|         ); |         ); | ||||||
|     } |     } | ||||||
|  | @ -40,7 +40,7 @@ mod tests { | ||||||
|     fn error_sugar() { |     fn error_sugar() { | ||||||
|         assert_expr!( |         assert_expr!( | ||||||
|             r#" |             r#" | ||||||
|             error "foo" |             fail "foo" | ||||||
|             "#
 |             "#
 | ||||||
|         ); |         ); | ||||||
|     } |     } | ||||||
|  | @ -7,7 +7,7 @@ pub mod assignment; | ||||||
| mod block; | mod block; | ||||||
| pub(crate) mod bytearray; | pub(crate) mod bytearray; | ||||||
| mod chained; | mod chained; | ||||||
| mod error_todo; | mod fail_todo; | ||||||
| mod if_else; | mod if_else; | ||||||
| mod int; | mod int; | ||||||
| mod list; | mod list; | ||||||
|  | @ -23,7 +23,7 @@ pub use anonymous_function::parser as anonymous_function; | ||||||
| pub use block::parser as block; | pub use block::parser as block; | ||||||
| pub use bytearray::parser as bytearray; | pub use bytearray::parser as bytearray; | ||||||
| pub use chained::parser as chained; | 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 if_else::parser as if_else; | ||||||
| pub use int::parser as int; | pub use int::parser as int; | ||||||
| pub use list::parser as list; | pub use list::parser as list; | ||||||
|  | @ -43,7 +43,7 @@ pub fn parser( | ||||||
| ) -> impl Parser<Token, UntypedExpr, Error = ParseError> + '_ { | ) -> impl Parser<Token, UntypedExpr, Error = ParseError> + '_ { | ||||||
|     recursive(|expression| { |     recursive(|expression| { | ||||||
|         choice(( |         choice(( | ||||||
|             error_todo(sequence.clone()), |             fail_todo(sequence.clone()), | ||||||
|             pure_expression(sequence, expression), |             pure_expression(sequence, expression), | ||||||
|         )) |         )) | ||||||
|     }) |     }) | ||||||
|  |  | ||||||
|  | @ -1,15 +1,15 @@ | ||||||
| --- | --- | ||||||
| source: crates/aiken-lang/src/parser/expr/error_todo.rs | source: crates/aiken-lang/src/parser/expr/fail_todo.rs | ||||||
| description: "Code:\n\nerror @\"foo\"\n" | description: "Code:\n\nfail @\"foo\"\n" | ||||||
| --- | --- | ||||||
| Trace { | Trace { | ||||||
|     kind: Error, |     kind: Error, | ||||||
|     location: 0..12, |     location: 0..11, | ||||||
|     then: ErrorTerm { |     then: ErrorTerm { | ||||||
|         location: 0..12, |         location: 0..11, | ||||||
|     }, |     }, | ||||||
|     text: String { |     text: String { | ||||||
|         location: 6..12, |         location: 5..11, | ||||||
|         value: "foo", |         value: "foo", | ||||||
|     }, |     }, | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,15 +1,15 @@ | ||||||
| --- | --- | ||||||
| source: crates/aiken-lang/src/parser/expr/error_todo.rs | source: crates/aiken-lang/src/parser/expr/fail_todo.rs | ||||||
| description: "Code:\n\nerror \"foo\"\n" | description: "Code:\n\nfail \"foo\"\n" | ||||||
| --- | --- | ||||||
| Trace { | Trace { | ||||||
|     kind: Error, |     kind: Error, | ||||||
|     location: 0..11, |     location: 0..10, | ||||||
|     then: ErrorTerm { |     then: ErrorTerm { | ||||||
|         location: 0..11, |         location: 0..10, | ||||||
|     }, |     }, | ||||||
|     text: String { |     text: String { | ||||||
|         location: 6..11, |         location: 5..10, | ||||||
|         value: "foo", |         value: "foo", | ||||||
|     }, |     }, | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -63,7 +63,7 @@ mod tests { | ||||||
|         assert_expr!( |         assert_expr!( | ||||||
|             r#" |             r#" | ||||||
|             when val is { |             when val is { | ||||||
|               Bar1{..} -> error |               Bar1{..} -> fail | ||||||
|             } |             } | ||||||
|             "#
 |             "#
 | ||||||
|         ); |         ); | ||||||
|  |  | ||||||
|  | @ -1,16 +1,16 @@ | ||||||
| --- | --- | ||||||
| source: crates/aiken-lang/src/parser/expr/when/clause.rs | 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 { | When { | ||||||
|     location: 0..35, |     location: 0..34, | ||||||
|     subject: Var { |     subject: Var { | ||||||
|         location: 5..8, |         location: 5..8, | ||||||
|         name: "val", |         name: "val", | ||||||
|     }, |     }, | ||||||
|     clauses: [ |     clauses: [ | ||||||
|         UntypedClause { |         UntypedClause { | ||||||
|             location: 16..33, |             location: 16..32, | ||||||
|             patterns: [ |             patterns: [ | ||||||
|                 Constructor { |                 Constructor { | ||||||
|                     is_record: true, |                     is_record: true, | ||||||
|  | @ -26,12 +26,12 @@ When { | ||||||
|             guard: None, |             guard: None, | ||||||
|             then: Trace { |             then: Trace { | ||||||
|                 kind: Error, |                 kind: Error, | ||||||
|                 location: 28..33, |                 location: 28..32, | ||||||
|                 then: ErrorTerm { |                 then: ErrorTerm { | ||||||
|                     location: 28..33, |                     location: 28..32, | ||||||
|                 }, |                 }, | ||||||
|                 text: String { |                 text: String { | ||||||
|                     location: 28..33, |                     location: 28..32, | ||||||
|                     value: "aiken::error", |                     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() { |     let keyword = text::ident().map(|s: String| match s.as_str() { | ||||||
|         "trace" => Token::Trace, |         "trace" => Token::Trace, | ||||||
|         "error" => Token::ErrorTerm, |         "fail" => Token::Fail, | ||||||
|  |         // TODO: delete this eventually
 | ||||||
|  |         "error" => Token::Fail, | ||||||
|         "as" => Token::As, |         "as" => Token::As, | ||||||
|         "assert" => Token::Expect, |         "assert" => Token::Expect, | ||||||
|         "expect" => Token::Expect, |         "expect" => Token::Expect, | ||||||
|  |  | ||||||
|  | @ -74,7 +74,7 @@ pub enum Token { | ||||||
|     Fn, |     Fn, | ||||||
|     If, |     If, | ||||||
|     Else, |     Else, | ||||||
|     ErrorTerm, |     Fail, | ||||||
|     Expect, |     Expect, | ||||||
|     Is, |     Is, | ||||||
|     Let, |     Let, | ||||||
|  | @ -170,7 +170,7 @@ impl fmt::Display for Token { | ||||||
|             Token::Trace => "trace", |             Token::Trace => "trace", | ||||||
|             Token::Type => "type", |             Token::Type => "type", | ||||||
|             Token::Test => "test", |             Token::Test => "test", | ||||||
|             Token::ErrorTerm => "error", |             Token::Fail => "fail", | ||||||
|             Token::Validator => "validator", |             Token::Validator => "validator", | ||||||
|         }; |         }; | ||||||
|         write!(f, "\"{s}\"") |         write!(f, "\"{s}\"") | ||||||
|  |  | ||||||
|  | @ -247,7 +247,7 @@ fn test_format_nested_function_calls() { | ||||||
|             , |             , | ||||||
|             when output.datum is { |             when output.datum is { | ||||||
|               InlineDatum(_) -> True |               InlineDatum(_) -> True | ||||||
|               _ -> error "expected inline datum" |               _ -> fail "expected inline datum" | ||||||
|             }, |             }, | ||||||
|           ] |           ] | ||||||
|           |> list.and |           |> list.and | ||||||
|  | @ -271,13 +271,13 @@ fn test_format_trace_todo_error() { | ||||||
|         fn foo_3() { |         fn foo_3() { | ||||||
|           when x is { |           when x is { | ||||||
|             Foo -> True |             Foo -> True | ||||||
|             _ -> error |             _ -> fail | ||||||
|           } |           } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         fn foo_4() { |         fn foo_4() { | ||||||
|           if 14 == 42 { |           if 14 == 42 { | ||||||
|             error "I don't think so" |             fail "I don't think so" | ||||||
|           } else { |           } else { | ||||||
|             trace "been there" |             trace "been there" | ||||||
|             True |             True | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| --- | --- | ||||||
| source: crates/aiken-lang/src/tests/format.rs | 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) { | fn foo(output) { | ||||||
|   [ |   [ | ||||||
|  | @ -13,7 +13,7 @@ fn foo(output) { | ||||||
|     ), |     ), | ||||||
|     when output.datum is { |     when output.datum is { | ||||||
|       InlineDatum(_) -> True |       InlineDatum(_) -> True | ||||||
|       _ -> error @"expected inline datum" |       _ -> fail @"expected inline datum" | ||||||
|     }, |     }, | ||||||
|   ] |   ] | ||||||
|     |> list.and |     |> list.and | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| --- | --- | ||||||
| source: crates/aiken-lang/src/tests/format.rs | 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() { | fn foo_1() { | ||||||
|   todo |   todo | ||||||
|  | @ -13,13 +13,13 @@ fn foo_2() { | ||||||
| fn foo_3() { | fn foo_3() { | ||||||
|   when x is { |   when x is { | ||||||
|     Foo -> True |     Foo -> True | ||||||
|     _ -> error |     _ -> fail | ||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| fn foo_4() { | fn foo_4() { | ||||||
|   if 14 == 42 { |   if 14 == 42 { | ||||||
|     error @"I don't think so" |     fail @"I don't think so" | ||||||
|   } else { |   } else { | ||||||
|     trace @"been there" |     trace @"been there" | ||||||
|     True |     True | ||||||
|  |  | ||||||
|  | @ -2601,7 +2601,7 @@ fn when_bool_is_true() { | ||||||
|           True -> |           True -> | ||||||
|             True |             True | ||||||
|           False -> |           False -> | ||||||
|             error |             fail | ||||||
|         } |         } | ||||||
|       }    
 |       }    
 | ||||||
|     "#;
 |     "#;
 | ||||||
|  | @ -2622,7 +2622,7 @@ fn when_bool_is_true_switched_cases() { | ||||||
|       test it() { |       test it() { | ||||||
|         when True is { |         when True is { | ||||||
|           False -> |           False -> | ||||||
|             error |             fail | ||||||
|           True -> |           True -> | ||||||
|             True |             True | ||||||
|         } |         } | ||||||
|  | @ -2645,7 +2645,7 @@ fn when_bool_is_false() { | ||||||
|       test it() { |       test it() { | ||||||
|         when False is { |         when False is { | ||||||
|           False -> |           False -> | ||||||
|             error |             fail | ||||||
|           True -> |           True -> | ||||||
|             True |             True | ||||||
|         } |         } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 rvcas
						rvcas