Browse Source

Merge pull request #4494 from jakubtomsu/min-max-one-numeric-param-error

[checker] Report error when builtin `min`/`max` has only one numeric parameter
Jeroen van Rijn 9 months ago
parent
commit
d118f88cd5
2 changed files with 10 additions and 1 deletions
  1. 1 1
      core/encoding/hxa/read.odin
  2. 9 0
      src/check_builtin.cpp

+ 1 - 1
core/encoding/hxa/read.odin

@@ -117,7 +117,7 @@ read :: proc(data: []byte, filename := "<input>", print_error := false, allocato
 			layer.name = read_name(r) or_return
 			layer.name = read_name(r) or_return
 			layer.components = read_value(r, u8) or_return
 			layer.components = read_value(r, u8) or_return
 			type := read_value(r, Layer_Data_Type) or_return
 			type := read_value(r, Layer_Data_Type) or_return
-			if type > max(type) {
+			if type > max(Layer_Data_Type) {
 				if r.print_error {
 				if r.print_error {
 					fmt.eprintf("HxA Error: file '%s' has layer data type %d. Maximum value is %d\n",
 					fmt.eprintf("HxA Error: file '%s' has layer data type %d. Maximum value is %d\n",
 								r.filename, u8(type), u8(max(Layer_Data_Type)))
 								r.filename, u8(type), u8(max(Layer_Data_Type)))

+ 9 - 0
src/check_builtin.cpp

@@ -3170,6 +3170,10 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
 			return false;
 			return false;
 		}
 		}
 
 
+		if (ce->args.count <= 1) {
+			error(call, "Too few arguments for 'min', two or more are required");
+			return false;
+		}
 
 
 		bool all_constant = operand->mode == Addressing_Constant;
 		bool all_constant = operand->mode == Addressing_Constant;
 
 
@@ -3343,6 +3347,11 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
 			gb_string_free(type_str);
 			gb_string_free(type_str);
 			return false;
 			return false;
 		}
 		}
+		
+		if (ce->args.count <= 1) {
+			error(call, "Too few arguments for 'max', two or more are required");
+			return false;
+		}
 
 
 		bool all_constant = operand->mode == Addressing_Constant;
 		bool all_constant = operand->mode == Addressing_Constant;