From e31bf47913276ffb5f0d839dc1976d58f8cfbcaa Mon Sep 17 00:00:00 2001 From: kalsprite Date: Tue, 11 Aug 2026 19:44:08 -0700 Subject: [PATCH 1/2] correct error guard --- src/check_builtin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index 4910dafb0..05b5d589e 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -5116,7 +5116,7 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As Operand o = {}; check_expr(c, &o, ce->args[0]); - if (!is_type_integer(o.type) && (o.mode != Addressing_Constant)) { + if (!is_type_integer(o.type) || o.mode != Addressing_Constant) { error(ce->args[0], "Expected a constant integer for '%.*s'", LIT(builtin_name)); return false; } @@ -5137,7 +5137,7 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As Operand o = {}; check_expr(c, &o, ce->args[0]); - if (!is_type_integer_or_float(o.type) && (o.mode != Addressing_Constant)) { + if (!is_type_integer_or_float(o.type) || o.mode != Addressing_Constant) { error(ce->args[0], "Expected a constant number for '%.*s'", LIT(builtin_name)); return false; } From 419050f82a44e082d6ed3613138c9763745292d8 Mon Sep 17 00:00:00 2001 From: kalsprite Date: Tue, 11 Aug 2026 22:52:33 -0700 Subject: [PATCH 2/2] fix four more guards using && where they need || --- src/check_builtin.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index 05b5d589e..98c6a297d 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -2667,7 +2667,7 @@ gb_internal bool check_builtin_procedure_directive(CheckerContext *c, Operand *o error(call, "'#panic' expects 1 argument, got %td", ce->args.count); return false; } - if (!is_type_string(operand->type) && operand->mode != Addressing_Constant) { + if (!is_type_string(operand->type) || operand->mode != Addressing_Constant) { gbString str = expr_to_string(ce->args[0]); error(call, "'%s' is not a constant string", str); gb_string_free(str); @@ -4928,7 +4928,7 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As return false; } - if (!is_type_array(x.type) && !is_type_array(y.type)) { + if (!is_type_array(x.type) || !is_type_array(y.type)) { gbString s1 = type_to_string(x.type); gbString s2 = type_to_string(y.type); error(call, "'%.*s' expects only arrays, got %s and %s", LIT(builtin_name), s1, s2); @@ -5058,7 +5058,7 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As case BuiltinProc_is_package_imported: { bool value = false; - if (!is_type_string(operand->type) && (operand->mode != Addressing_Constant)) { + if (!is_type_string(operand->type) || operand->mode != Addressing_Constant) { error(ce->args[0], "Expected a constant string for '%.*s'", LIT(builtin_name)); } else if (operand->value.kind == ExactValue_String) { String pkg_name = operand->value.value_string; @@ -6709,7 +6709,7 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As if (x.mode == Addressing_Invalid) { return false; } - if (y.mode != Addressing_Constant && is_type_integer(y.type)) { + if (y.mode != Addressing_Constant || !is_type_integer(y.type)) { error(y.expr, "Second argument to '%.*s' representing the locality must be an integer in the range 0..=3", LIT(builtin_name)); return false; }