From 3f540c7c99b01e014f7fc9fe3f783ae4842083b9 Mon Sep 17 00:00:00 2001 From: rvcas Date: Thu, 9 Feb 2023 00:47:38 -0500 Subject: [PATCH] chore: rename assignment kind --- crates/aiken-lang/src/ast.rs | 4 ++-- crates/aiken-lang/src/format.rs | 2 +- crates/aiken-lang/src/parser.rs | 2 +- crates/aiken-lang/src/tests/parser.rs | 2 +- crates/aiken-lang/src/tipo/error.rs | 2 +- crates/aiken-lang/src/tipo/expr.rs | 2 +- crates/aiken-lang/src/uplc.rs | 14 +++++++------- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/crates/aiken-lang/src/ast.rs b/crates/aiken-lang/src/ast.rs index 4c8da18d..51ba9e2d 100644 --- a/crates/aiken-lang/src/ast.rs +++ b/crates/aiken-lang/src/ast.rs @@ -766,7 +766,7 @@ impl Pattern { #[derive(Debug, Clone, PartialEq, Eq, Copy)] pub enum AssignmentKind { Let, - Assert, + Expect, } impl AssignmentKind { @@ -775,7 +775,7 @@ impl AssignmentKind { } pub fn is_assert(&self) -> bool { - matches!(self, AssignmentKind::Assert) + matches!(self, AssignmentKind::Expect) } } diff --git a/crates/aiken-lang/src/format.rs b/crates/aiken-lang/src/format.rs index 6bb0a76c..8134340d 100644 --- a/crates/aiken-lang/src/format.rs +++ b/crates/aiken-lang/src/format.rs @@ -606,7 +606,7 @@ impl<'comments> Formatter<'comments> { let keyword = match kind { Some(AssignmentKind::Let) => "let ", - Some(AssignmentKind::Assert) => "assert ", + Some(AssignmentKind::Expect) => "assert ", None => "try ", }; diff --git a/crates/aiken-lang/src/parser.rs b/crates/aiken-lang/src/parser.rs index e9163e21..4760e0c0 100644 --- a/crates/aiken-lang/src/parser.rs +++ b/crates/aiken-lang/src/parser.rs @@ -1038,7 +1038,7 @@ pub fn expr_parser( location: span, value: Box::new(value), pattern, - kind: ast::AssignmentKind::Assert, + kind: ast::AssignmentKind::Expect, annotation, }, ); diff --git a/crates/aiken-lang/src/tests/parser.rs b/crates/aiken-lang/src/tests/parser.rs index e71f882e..3837ef73 100644 --- a/crates/aiken-lang/src/tests/parser.rs +++ b/crates/aiken-lang/src/tests/parser.rs @@ -369,7 +369,7 @@ fn expect() { with_spread: false, tipo: (), }, - kind: ast::AssignmentKind::Assert, + kind: ast::AssignmentKind::Expect, annotation: None, }, expr::UntypedExpr::FieldAccess { diff --git a/crates/aiken-lang/src/tipo/error.rs b/crates/aiken-lang/src/tipo/error.rs index 2c0fed74..9be75612 100644 --- a/crates/aiken-lang/src/tipo/error.rs +++ b/crates/aiken-lang/src/tipo/error.rs @@ -333,7 +333,7 @@ Perhaps, try the following: #[diagnostic(code("illegal::module_name"))] #[diagnostic(help(r#"You cannot use keywords as part of a module path name. As a quick reminder, here's a list of all the keywords (and thus, of invalid module path names): - as, assert, check, const, else, fn, if, is, let, opaque, pub, test, todo, trace, type, use, when"#))] + as, expect, check, const, else, fn, if, is, let, opaque, pub, test, todo, trace, type, use, when"#))] KeywordInModuleName { name: String, keyword: String }, #[error("I discovered a function which is ending with an assignment.\n")] diff --git a/crates/aiken-lang/src/tipo/expr.rs b/crates/aiken-lang/src/tipo/expr.rs index 3787b991..fd0915fb 100644 --- a/crates/aiken-lang/src/tipo/expr.rs +++ b/crates/aiken-lang/src/tipo/expr.rs @@ -877,7 +877,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> { // We currently only do limited exhaustiveness checking of custom types // at the top level of patterns. // Do not perform exhaustiveness checking if user explicitly used `assert`. - if kind != AssignmentKind::Assert { + if kind != AssignmentKind::Expect { if let Err(unmatched) = self.environment.check_exhaustiveness( vec![pattern.clone()], collapse_links(value_typ.clone()), diff --git a/crates/aiken-lang/src/uplc.rs b/crates/aiken-lang/src/uplc.rs index 15384e91..a2679763 100644 --- a/crates/aiken-lang/src/uplc.rs +++ b/crates/aiken-lang/src/uplc.rs @@ -1578,7 +1578,7 @@ impl<'a> CodeGenerator<'a> { pattern_vec.append(value_vec); - if matches!(assignment_properties.kind, AssignmentKind::Assert) + if matches!(assignment_properties.kind, AssignmentKind::Expect) && assignment_properties.value_type.is_data() && !tipo.is_data() { @@ -1604,7 +1604,7 @@ impl<'a> CodeGenerator<'a> { pattern_vec.append(value_vec); } list @ Pattern::List { .. } => { - if matches!(assignment_properties.kind, AssignmentKind::Assert) + if matches!(assignment_properties.kind, AssignmentKind::Expect) && assignment_properties.value_type.is_data() && !tipo.is_data() { @@ -1629,7 +1629,7 @@ impl<'a> CodeGenerator<'a> { } // TODO: Check constr for assert on all cases constr @ Pattern::Constructor { .. } => { - if matches!(assignment_properties.kind, AssignmentKind::Assert) + if matches!(assignment_properties.kind, AssignmentKind::Expect) && assignment_properties.value_type.is_data() && !tipo.is_data() { @@ -1653,7 +1653,7 @@ impl<'a> CodeGenerator<'a> { } } tuple @ Pattern::Tuple { .. } => { - if matches!(assignment_properties.kind, AssignmentKind::Assert) + if matches!(assignment_properties.kind, AssignmentKind::Expect) && assignment_properties.value_type.is_data() && !tipo.is_data() { @@ -2503,7 +2503,7 @@ impl<'a> CodeGenerator<'a> { let id = self.id_gen.next(); let list_name = format!("__list_{id}"); - if matches!(assignment_properties.kind, AssignmentKind::Assert) + if matches!(assignment_properties.kind, AssignmentKind::Expect) && assignment_properties.value_type.is_data() && !tipo.is_data() { @@ -2556,7 +2556,7 @@ impl<'a> CodeGenerator<'a> { let id = self.id_gen.next(); let constr_name = format!("{constr_name}_{id}"); - if matches!(assignment_properties.kind, AssignmentKind::Assert) + if matches!(assignment_properties.kind, AssignmentKind::Expect) && assignment_properties.value_type.is_data() && !tipo.is_data() { @@ -2605,7 +2605,7 @@ impl<'a> CodeGenerator<'a> { let id = self.id_gen.next(); let tuple_name = format!("__tuple_name_{id}"); - if matches!(assignment_properties.kind, AssignmentKind::Assert) + if matches!(assignment_properties.kind, AssignmentKind::Expect) && assignment_properties.value_type.is_data() && !tipo.is_data() {