From 25ce7e87de16402ca672f4109152cb46c750257e Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 9 Aug 2026 18:52:57 +0100 Subject: [PATCH] Correctly type check `asm` template parameters --- src/check_decl.cpp | 2 ++ src/check_expr.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/check_decl.cpp b/src/check_decl.cpp index f1ab06a52..ea35e96c5 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -2419,6 +2419,8 @@ gb_internal void check_asm_template(CheckerContext *ctx, Entity *entity, DeclInf Type *type = alloc_type_proc(ate->param_scope, params, params->Tuple.variables.count, results, results->Tuple.variables.count, false, pt->calling_convention); type->Proc.diverging = pt->diverging; + entity->type = type; + check_asm_specs(ctx, ate->param_scope, at->specs, &ate->decls); { // check clobbers for (Ast *clobber_ : at->clobbers) { diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 566a0ff28..cf6c45d05 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -5933,7 +5933,8 @@ gb_internal Entity *check_selector(CheckerContext *c, Operand *operand, Ast *nod add_entity_use(c, op_expr, e); expr_entity = e; - if (e != nullptr && (e->kind == Entity_Procedure || e->kind == Entity_ProcGroup) && selector->kind == Ast_Ident) { + if (e != nullptr && (e->kind == Entity_Procedure || e->kind == Entity_ProcGroup || e->kind == Entity_AsmTemplate) && + selector->kind == Ast_Ident) { gbString sel_str = expr_to_string(selector); error(node, "'%s' is not declared by '%.*s'", sel_str, LIT(e->token.string)); gb_string_free(sel_str); @@ -6304,6 +6305,10 @@ gb_internal Entity *check_selector(CheckerContext *c, Operand *operand, Ast *nod case Entity_Nil: operand->mode = Addressing_Value; break; + + case Entity_AsmTemplate: + operand->mode = Addressing_Value; + break; } add_type_and_value(c, operand->expr, operand->mode, operand->type, operand->value);