aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormartinhath <martinhath@users.noreply.github.com>2022-08-26 10:37:17 +0200
committerGitHub <noreply@github.com>2022-08-26 11:37:17 +0300
commit3fa5415253695001149ad65ae6f2ca8d0fa63565 (patch)
tree0dfb0d0db54dd2d7c00490daf7e41aef4107fdaf /src
parentbcaa9df5b42747577dcb529a99f6da6d69e09309 (diff)
downloadzig-3fa5415253695001149ad65ae6f2ca8d0fa63565.tar.gz
zig-3fa5415253695001149ad65ae6f2ca8d0fa63565.zip
Sema: ensure resolveTypeFields is called for optional and error union types
We call `sema.resolveTypeFields` in order to get the fields of structs and unions inserted into their data structures. If it isn't called, it can happen that the fields of a type is queried before those fields are inserted into (for instance) `Module.Union.fields`, which would result in a wrong 'no field named' error. Fixes: #12486
Diffstat (limited to 'src')
-rw-r--r--src/Sema.zig5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index fc2a7f872a..2907999c25 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -16190,9 +16190,10 @@ fn fieldType(
field_src: LazySrcLoc,
ty_src: LazySrcLoc,
) CompileError!Air.Inst.Ref {
- const resolved_ty = try sema.resolveTypeFields(block, ty_src, aggregate_ty);
- var cur_ty = resolved_ty;
+ var cur_ty = aggregate_ty;
while (true) {
+ const resolved_ty = try sema.resolveTypeFields(block, ty_src, cur_ty);
+ cur_ty = resolved_ty;
switch (cur_ty.zigTypeTag()) {
.Struct => {
if (cur_ty.isAnonStruct()) {