Set target in test.

This commit is contained in:
Christoffer Lerno
2026-01-29 02:30:06 +01:00
parent 32b1df0f86
commit 084d5cbc94
2 changed files with 11 additions and 2 deletions

View File

@@ -6370,10 +6370,11 @@ static inline bool sema_expr_analyse_access(SemaContext *context, Expr *expr, bo
if (parent->expr_kind == EXPR_TYPEINFO) if (parent->expr_kind == EXPR_TYPEINFO)
{ {
Type *type = parent->type_expr->type->canonical; Type *type = parent->type_expr->type->canonical;
switch (type->type_kind) switch (type_no_optional(type)->type_kind)
{ {
case CT_TYPES: case CT_TYPES:
RETURN_SEMA_ERROR(parent, "You cannot take the typeid of a compile time type."); RETURN_SEMA_ERROR(parent, "You cannot take the typeid of a compile time type.");
default: default:
expr_rewrite_const_typeid(expr, parent->type_expr->type->canonical); expr_rewrite_const_typeid(expr, parent->type_expr->type->canonical);
return true; return true;
@@ -12068,7 +12069,7 @@ static inline bool sema_cast_rvalue(SemaContext *context, Expr *expr, bool mutat
} }
return true; return true;
case EXPR_TYPEINFO: case EXPR_TYPEINFO:
switch (expr->type_expr->type->type_kind) switch (type_no_optional(expr->type_expr->type)->type_kind)
{ {
case CT_TYPES: case CT_TYPES:
RETURN_SEMA_ERROR(expr, "You cannot take the typeid of a compile time type."); RETURN_SEMA_ERROR(expr, "You cannot take the typeid of a compile time type.");

View File

@@ -0,0 +1,8 @@
macro test(x)
{
}
fn int main()
{
test($typeof({})?); // #error: You cannot take the typeid of a compile time type
return 0;
}