Fix missing error when calling argb() with too many arguments

This is technically a breaking change if someone was calling it with too
many args by mistake, but i think it's fine to do this as a bugfix
This commit is contained in:
Olivier Goffart 2024-03-22 14:00:12 +01:00
parent ed2816331e
commit 42a4286048
2 changed files with 17 additions and 2 deletions

View file

@ -187,8 +187,11 @@ fn rgb_macro(
args: Vec<(Expression, Option<NodeOrToken>)>,
diag: &mut BuildDiagnostics,
) -> Expression {
if args.len() < 3 {
diag.push_error("Needs 3 or 4 argument".into(), &node);
if args.len() < 3 || args.len() > 4 {
diag.push_error(
format!("This function needs 3 or 4 arguments, but {} were provided", args.len()),
&node,
);
return Expression::Invalid;
}
let mut arguments: Vec<_> = args