aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2025-03-10 22:18:56 +0000
committerMatthew Lugg <mlugg@mlugg.co.uk>2025-03-11 13:13:52 +0000
commit423907c2700ae5812a6abccca8cf6db29c7dad9e (patch)
tree667d799ff9a8d4bc5a8247ad8e6b648c9acf17cb /src
parent7e751e8040ad6afb9ae0a040ae4080c2f4b2f443 (diff)
downloadzig-423907c2700ae5812a6abccca8cf6db29c7dad9e.tar.gz
zig-423907c2700ae5812a6abccca8cf6db29c7dad9e.zip
Sema: fix handling of `@This()` on opaques
Resolves: #22869
Diffstat (limited to 'src')
-rw-r--r--src/Sema.zig18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index 7e14d3046e..91acbeeb59 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -17841,11 +17841,18 @@ fn zirThis(
const zcu = pt.zcu;
const namespace = pt.zcu.namespacePtr(block.namespace);
- const new_ty = try pt.ensureTypeUpToDate(namespace.owner_type);
-
- switch (pt.zcu.intern_pool.indexToKey(new_ty)) {
- .struct_type, .union_type => try sema.declareDependency(.{ .interned = new_ty }),
+ switch (pt.zcu.intern_pool.indexToKey(namespace.owner_type)) {
+ .opaque_type => {
+ // Opaque types are never outdated since they don't undergo type resolution, so nothing to do!
+ return Air.internedToRef(namespace.owner_type);
+ },
+ .struct_type, .union_type => {
+ const new_ty = try pt.ensureTypeUpToDate(namespace.owner_type);
+ try sema.declareDependency(.{ .interned = new_ty });
+ return Air.internedToRef(new_ty);
+ },
.enum_type => {
+ const new_ty = try pt.ensureTypeUpToDate(namespace.owner_type);
try sema.declareDependency(.{ .interned = new_ty });
// Since this is an enum, it has to be resolved immediately.
// `ensureTypeUpToDate` has resolved the new type if necessary.
@@ -17854,11 +17861,10 @@ fn zirThis(
if (zcu.failed_analysis.contains(ty_unit) or zcu.transitive_failed_analysis.contains(ty_unit)) {
return error.AnalysisFail;
}
+ return Air.internedToRef(new_ty);
},
- .opaque_type => {},
else => unreachable,
}
- return Air.internedToRef(new_ty);
}
fn zirClosureGet(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref {