Allow #no_alias on any pointer-like type

This commit is contained in:
gingerBill
2026-07-01 01:21:49 +01:00
parent 957789d85a
commit 45eed87309
2 changed files with 4 additions and 3 deletions

View File

@@ -2221,8 +2221,9 @@ gb_internal Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_para
}
if (p->flags&FieldFlag_no_alias) {
if (!is_type_pointer(type) && !is_type_multi_pointer(type)) {
error(name, "'#no_alias' can only be applied pointer or multi-pointer typed parameters");
bool ok = is_type_internally_pointer_like(type);
if (!ok) {
error(name, "'#no_alias' can only be applied pointer-like type parameters");
p->flags &= ~FieldFlag_no_alias; // Remove the flag
}
}

View File

@@ -1529,7 +1529,7 @@ gb_internal bool is_type_multi_pointer(Type *t) {
return t->kind == Type_MultiPointer;
}
gb_internal bool is_type_internally_pointer_like(Type *t) {
return is_type_pointer(t) || is_type_multi_pointer(t) || is_type_cstring(t) || is_type_proc(t);
return is_type_pointer(t) || is_type_multi_pointer(t) || is_type_cstring(t) || is_type_cstring16(t) || is_type_proc(t);
}
gb_internal bool is_type_tuple(Type *t) {