From 0314c91a64ae105a85657b59c7f2010cb48f8e5d Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 15 Mar 2026 16:14:46 +0000 Subject: [PATCH] Add error message for `foo := Foo{&foo}` where the type of `foo` is not determined yet --- src/check_expr.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 492b38ffa..e66498b6d 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -12009,6 +12009,17 @@ gb_internal ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast if (o->mode != Addressing_Invalid) { check_unary_expr(c, o, ue->op, node); + } else { + ERROR_BLOCK(); + gbString s = expr_to_string(ue->expr); + defer (gb_string_free(s)); + + error(node, "Cannot address value '%s' as it has not got a determined type yet", s); + + Entity *e = entity_of_node(ue->expr); + if (e != nullptr && e->kind == Entity_Variable) { + error_line("\tSuggestion: Add an explicit type to the declaration of '%.*s' rather than relying on type inference", LIT(e->token.string)); + } } o->expr = node; return Expr_Expr;