diff options
| author | fmaggi <61335294+fmaggi@users.noreply.github.com> | 2024-07-15 04:58:33 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-15 10:58:33 +0300 |
| commit | 583e698256a2a26f26738c983e319d76926ef048 (patch) | |
| tree | fa3ac65a89e627f5c4b361282f8bf0f20dbc78d1 /src | |
| parent | d404d8a3637bc30dffc736e5fa1a68b8af0e19cb (diff) | |
| download | zig-583e698256a2a26f26738c983e319d76926ef048.tar.gz zig-583e698256a2a26f26738c983e319d76926ef048.zip | |
Sema: disallow casting to opaque
Diffstat (limited to 'src')
| -rw-r--r-- | src/Sema.zig | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index f5ee909caf..fdaad29995 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -10188,9 +10188,15 @@ fn analyzeAs( const dest_ty_tag = dest_ty.zigTypeTagOrPoison(mod) catch |err| switch (err) { error.GenericPoison => return operand, }; + + if (dest_ty_tag == .Opaque) { + return sema.fail(block, src, "cannot cast to opaque type '{}'", .{dest_ty.fmt(pt)}); + } + if (dest_ty_tag == .NoReturn) { return sema.fail(block, src, "cannot cast to noreturn", .{}); } + const is_ret = if (zir_dest_type.toIndex()) |ptr_index| sema.code.instructions.items(.tag)[@intFromEnum(ptr_index)] == .ret_type else |
