Fix polymorphic type parameter argument count checking #298

This commit is contained in:
gingerBill
2018-12-14 15:05:26 +00:00
parent 0b6fc19fb0
commit 26f11f12ab

View File

@@ -4970,6 +4970,18 @@ CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *oper
return err;
}
if (param_count < ordered_operands.count) {
error(call, "Too many polymorphic type arguments, expected %td, got %td", param_count, ordered_operands.count);
err = CallArgumentError_TooManyArguments;
} else if (param_count > ordered_operands.count) {
error(call, "Too few polymorphic type arguments, expected %td, got %td", param_count, ordered_operands.count);
err = CallArgumentError_TooFewArguments;
}
if (err != 0) {
return err;
}
i64 score = 0;
for (isize i = 0; i < param_count; i++) {
Operand *o = &ordered_operands[i];