| ... | @@ -15282,6 +15282,19 @@ fn structFieldPtrByIndex( | ... | @@ -15282,6 +15282,19 @@ fn structFieldPtrByIndex( |
| 15282 | const target = sema.mod.getTarget(); | 15282 | const target = sema.mod.getTarget(); |
| 15283 | const ptr_field_ty = try Type.ptr(sema.arena, target, ptr_ty_data); | 15283 | const ptr_field_ty = try Type.ptr(sema.arena, target, ptr_ty_data); |
| 15284 | | 15284 | |
| | 15285 | if (field.is_comptime) { |
| | 15286 | var anon_decl = try block.startAnonDecl(field_src); |
| | 15287 | defer anon_decl.deinit(); |
| | 15288 | const decl = try anon_decl.finish( |
| | 15289 | try field.ty.copy(anon_decl.arena()), |
| | 15290 | try field.default_val.copy(anon_decl.arena()), |
| | 15291 | ); |
| | 15292 | if (ptr_ty_data.@"align" != 0) { |
| | 15293 | decl.align_val = field.abi_align; |
| | 15294 | } |
| | 15295 | return sema.analyzeDeclRef(decl); |
| | 15296 | } |
| | 15297 | |
| 15285 | if (try sema.resolveDefinedValue(block, src, struct_ptr)) |struct_ptr_val| { | 15298 | if (try sema.resolveDefinedValue(block, src, struct_ptr)) |struct_ptr_val| { |
| 15286 | return sema.addConstant( | 15299 | return sema.addConstant( |
| 15287 | ptr_field_ty, | 15300 | ptr_field_ty, |
| ... | @@ -15330,6 +15343,10 @@ fn structFieldVal( | ... | @@ -15330,6 +15343,10 @@ fn structFieldVal( |
| 15330 | const field_index = @intCast(u32, field_index_usize); | 15343 | const field_index = @intCast(u32, field_index_usize); |
| 15331 | const field = struct_obj.fields.values()[field_index]; | 15344 | const field = struct_obj.fields.values()[field_index]; |
| 15332 | | 15345 | |
| | 15346 | if (field.is_comptime) { |
| | 15347 | return sema.addConstant(field.ty, field.default_val); |
| | 15348 | } |
| | 15349 | |
| 15333 | if (try sema.resolveMaybeUndefVal(block, src, struct_byval)) |struct_val| { | 15350 | if (try sema.resolveMaybeUndefVal(block, src, struct_byval)) |struct_val| { |
| 15334 | if (struct_val.isUndef()) return sema.addConstUndef(field.ty); | 15351 | if (struct_val.isUndef()) return sema.addConstUndef(field.ty); |
| 15335 | if ((try sema.typeHasOnePossibleValue(block, src, field.ty))) |opv| { | 15352 | if ((try sema.typeHasOnePossibleValue(block, src, field.ty))) |opv| { |