From e18b15e8f05d62b7bc8461dfe4bf4a8b92089752 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 17 Mar 2026 12:16:44 +0000 Subject: [PATCH] Move error-only things to the error scopes --- src/check_expr.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 0ba316697..2155485f5 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -1090,18 +1090,20 @@ gb_internal void check_assignment(CheckerContext *c, Operand *operand, Type *typ return; } - // Grab definite or indefinite article matching `context_name`, or "" if not found. - String article = error_article(context_name); if (is_type_untyped(operand->type)) { Type *target_type = type; if (type == nullptr || is_type_any(type)) { if (type == nullptr && is_type_untyped_uninit(operand->type)) { + String article = error_article(context_name); // Grab definite or indefinite article matching `context_name`, or "" if not found. + error(operand->expr, "Use of --- in %.*s%.*s", LIT(article), LIT(context_name)); operand->mode = Addressing_Invalid; return; } if (type == nullptr && is_type_untyped_nil(operand->type)) { + String article = error_article(context_name); // Grab definite or indefinite article matching `context_name`, or "" if not found. + error(operand->expr, "Use of untyped nil in %.*s%.*s", LIT(article), LIT(context_name)); operand->mode = Addressing_Invalid; return; @@ -1159,6 +1161,8 @@ gb_internal void check_assignment(CheckerContext *c, Operand *operand, Type *typ defer (gb_string_free(op_type_str)); defer (gb_string_free(expr_str)); + String article = error_article(context_name); // Grab definite or indefinite article matching `context_name`, or "" if not found. + // TODO(bill): is this a good enough error message? error(operand->expr, "Cannot assign overloaded procedure group '%s' to '%s' in %.*s%.*s", @@ -1187,6 +1191,8 @@ gb_internal void check_assignment(CheckerContext *c, Operand *operand, Type *typ defer (gb_string_free(op_type_str)); defer (gb_string_free(expr_str)); + String article = error_article(context_name); // Grab definite or indefinite article matching `context_name`, or "" if not found. + switch (operand->mode) { case Addressing_Builtin: error(operand->expr,