diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2025-01-03 23:48:27 +0000 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2025-01-04 05:44:29 +0000 |
| commit | f818098971fdafdaaa6af4b927f2cf47332ed5f7 (patch) | |
| tree | 68692d31a8c939887864ec302d8e8378c7c87cfd /src/InternPool.zig | |
| parent | 814491f59921600b8a0137733b48d4b0f6b99d78 (diff) | |
| download | zig-f818098971fdafdaaa6af4b927f2cf47332ed5f7.tar.gz zig-f818098971fdafdaaa6af4b927f2cf47332ed5f7.zip | |
incremental: correctly return `error.AnalysisFail` when type structure changes
`Zcu.PerThead.ensureTypeUpToDate` is set up in such a way that it only
returns the updated type the first time it is called. In general, that's
okay; however, the exception is that we want the function to continue
returning `error.AnalysisFail` when the type has been lost, or its
number of captures changed.
Therefore, the check for this case now happens before the up-to-date
success return.
For simplicity, the number of captures is now handled by intentionally
losing the instruction in `Zcu.mapOldZirToNew`, since there is nothing
to gain from tracking a type when old instances of it can never be
reused.
Diffstat (limited to 'src/InternPool.zig')
| -rw-r--r-- | src/InternPool.zig | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/InternPool.zig b/src/InternPool.zig index fdeddcfa2f..c0b4d2f446 100644 --- a/src/InternPool.zig +++ b/src/InternPool.zig @@ -2029,15 +2029,7 @@ pub const Key = union(enum) { pub const NamespaceType = union(enum) { /// This type corresponds to an actual source declaration, e.g. `struct { ... }`. /// It is hashed based on its ZIR instruction index and set of captures. - declared: struct { - /// A `struct_decl`, `union_decl`, `enum_decl`, or `opaque_decl` instruction. - zir_index: TrackedInst.Index, - /// The captured values of this type. These values must be fully resolved per the language spec. - captures: union(enum) { - owned: CaptureValue.Slice, - external: []const CaptureValue, - }, - }, + declared: Declared, /// This type is an automatically-generated enum tag type for a union. /// It is hashed based on the index of the union type it corresponds to. generated_tag: struct { @@ -2053,6 +2045,16 @@ pub const Key = union(enum) { /// A hash of this type's attributes, fields, etc, generated by Sema. type_hash: u64, }, + + pub const Declared = struct { + /// A `struct_decl`, `union_decl`, `enum_decl`, or `opaque_decl` instruction. + zir_index: TrackedInst.Index, + /// The captured values of this type. These values must be fully resolved per the language spec. + captures: union(enum) { + owned: CaptureValue.Slice, + external: []const CaptureValue, + }, + }; }; pub const FuncType = struct { |
