feat: new error for when multi-validators have the same arg count

This commit is contained in:
rvcas 2023-03-17 18:18:37 -04:00
parent d753b57c1b
commit 74c61358ab
No known key found for this signature in database
GPG Key ID: C09B64E263F7D68C
2 changed files with 19 additions and 0 deletions

View File

@ -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())

View File

@ -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();