Reject a non-constant argument to an template's immediate

This commit is contained in:
kalsprite
2026-08-23 22:22:15 -07:00
parent 965970af71
commit 6088dc8420
5 changed files with 51 additions and 2 deletions

View File

@@ -6996,6 +6996,18 @@ gb_internal CallArgumentError check_call_arguments_internal(CheckerContext *c, A
}
}
// an `asm` template's `$` parameter is encoded as an immediate, so only a constant can reach it
if (e && e->kind == Entity_Variable && (e->flags & EntityFlag_PolyConst)) {
if (o->mode != Addressing_Constant) {
if (show_error) {
gbString str = expr_to_string(o->expr);
error(o->expr, "Expected a constant value for the '$' immediate '%.*s', got %s", LIT(e->token.string), str);
gb_string_free(str);
}
err = CallArgumentError_NoneConstantParameter;
}
}
if (e && e->kind == Entity_Constant && is_type_proc(e->type)) {
bool ok = false;
if (o->mode == Addressing_Constant) {