From 71880eb1fff836b222fa2e98adecb52b3382edca Mon Sep 17 00:00:00 2001 From: jakubtomsu <66876057+jakubtomsu@users.noreply.github.com> Date: Sun, 17 Nov 2024 21:02:30 +0100 Subject: [PATCH 1/2] report error when builtin min/max has 1 (non-type) param --- src/check_builtin.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index 42b9e2180..c86503093 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -3170,6 +3170,10 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As 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; @@ -3343,6 +3347,11 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As gb_string_free(type_str); 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; From 86c84f2621c86dd904cd78354e4de51c3716ab42 Mon Sep 17 00:00:00 2001 From: jakubtomsu <66876057+jakubtomsu@users.noreply.github.com> Date: Sun, 17 Nov 2024 21:35:49 +0100 Subject: [PATCH 2/2] Fix a bug in hxa decoder found by the new check --- core/encoding/hxa/read.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/encoding/hxa/read.odin b/core/encoding/hxa/read.odin index 5c8503229..a679946f8 100644 --- a/core/encoding/hxa/read.odin +++ b/core/encoding/hxa/read.odin @@ -117,7 +117,7 @@ read :: proc(data: []byte, filename := "", print_error := false, allocato layer.name = read_name(r) or_return layer.components = read_value(r, u8) 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 { 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)))