From af9a785d65d23606f4ed9086ab1cf5d742068c8c Mon Sep 17 00:00:00 2001 From: KtorZ Date: Sun, 25 Aug 2024 17:08:46 +0200 Subject: [PATCH] Provide default annotation to validators (incl. fallback) Without that, we may encounter weird error messages when writing validators without an explicit `else`. Since we automatically fill it with a `fail`; without annotation, it unifies to a generic parameter. The existing check that would look for the body being an error term is ill-advised as it doesn't work as soon as one adds tracing, or make the validator a parameterized validator. Plus, it may simply trigger the wrong behavior as one can now annotate a validator with _whatever_ and get pass the type-checker by plucking a `fail` keyword as body. --- .../src/parser/definition/validator.rs | 63 ++++++++++--------- crates/aiken-lang/src/tipo/infer.rs | 3 +- crates/uplc/src/tx.rs | 4 +- 3 files changed, 36 insertions(+), 34 deletions(-) diff --git a/crates/aiken-lang/src/parser/definition/validator.rs b/crates/aiken-lang/src/parser/definition/validator.rs index 81f4c176..57e0d1bf 100644 --- a/crates/aiken-lang/src/parser/definition/validator.rs +++ b/crates/aiken-lang/src/parser/definition/validator.rs @@ -1,12 +1,10 @@ -use chumsky::prelude::*; - +use super::function::param; use crate::{ ast::{self, ArgBy, ArgName}, expr::UntypedExpr, parser::{annotation, error::ParseError, expr, token::Token}, }; - -use super::function::param; +use chumsky::prelude::*; pub fn parser() -> impl Parser { just(Token::Validator) @@ -52,36 +50,38 @@ pub fn parser() -> impl Parser impl Parser