diff --git a/crates/aiken-lang/src/tipo/error.rs b/crates/aiken-lang/src/tipo/error.rs index 786db0ac..160ebdc6 100644 --- a/crates/aiken-lang/src/tipo/error.rs +++ b/crates/aiken-lang/src/tipo/error.rs @@ -421,6 +421,17 @@ If you really meant to return that last expression, try to replace it with the f name: String, }, + #[error("I found a multi-validator where both take the same number of arguments.\n")] + #[diagnostic(code("illegal::multi_validator"))] + #[diagnostic(help("Multi-validators cannot take the same number of arguments. One must take 3 arguments\nand the other must take 2 arguments. Both of these take {} arguments.", count.to_string().purple()))] + MultiValidatorEqualArgs { + #[label("{} here", count)] + location: Span, + #[label("and {} here", count)] + other_location: Span, + count: usize, + }, + #[error( "I stumbled upon an invalid (non-local) clause guard '{}'.\n", name.if_supports_color(Stdout, |s| s.purple()) diff --git a/crates/aiken-lang/src/tipo/infer.rs b/crates/aiken-lang/src/tipo/infer.rs index 07e8db42..a8e030c0 100644 --- a/crates/aiken-lang/src/tipo/infer.rs +++ b/crates/aiken-lang/src/tipo/infer.rs @@ -323,6 +323,14 @@ fn infer_definition( }); } + if typed_fun.arguments.len() == other_typed_fun.arguments.len() { + return Err(Error::MultiValidatorEqualArgs { + location: typed_fun.location, + other_location: other_typed_fun.location, + count: other_typed_fun.arguments.len(), + }); + } + Ok(other_typed_fun) }) .transpose();