Browse Source

Fix polymorphic type parameter argument count checking #298

gingerBill 6 years ago
parent
commit
26f11f12ab
1 changed files with 12 additions and 0 deletions
  1. 12 0
      src/check_expr.cpp

+ 12 - 0
src/check_expr.cpp

@@ -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];