| author | |
| committer | |
| log | 28353b315935e54b497f4abb875fac387e20f65f |
| tree | 79c2a081157b231038f5ff54abf3166abd3c66eb |
| parent | 73bf53069d4e719cb74be87bd41b0a2ac65b7dfe |
4 files changed, 15 insertions(+), 11 deletions(-)
BRANCH_TODO+2| ... | @@ -1,3 +1,5 @@ | ... | @@ -1,3 +1,5 @@ |
| 1 | * structs, unions, enums, etc get weird names such as "Point__anon_22" rather | ||
| 2 | than "Point". | ||
| 1 | * get stage2 tests passing | 3 | * get stage2 tests passing |
| 2 | * modify stage2 tests so that only 1 uses _start and the rest use | 4 | * modify stage2 tests so that only 1 uses _start and the rest use |
| 3 | pub fn main | 5 | pub fn main |
src/Module.zig+6-2| ... | @@ -4416,7 +4416,9 @@ pub fn analyzeStructFields(mod: *Module, struct_obj: *Struct) InnerError!void { | ... | @@ -4416,7 +4416,9 @@ pub fn analyzeStructFields(mod: *Module, struct_obj: *Struct) InnerError!void { |
| 4416 | }; | 4416 | }; |
| 4417 | defer assert(block.instructions.items.len == 0); // should all be comptime instructions | 4417 | defer assert(block.instructions.items.len == 0); // should all be comptime instructions |
| 4418 | 4418 | ||
| 4419 | _ = try sema.analyzeBody(&block, body); | 4419 | if (body.len != 0) { |
| 4420 | _ = try sema.analyzeBody(&block, body); | ||
| 4421 | } | ||
| 4420 | 4422 | ||
| 4421 | const bits_per_field = 4; | 4423 | const bits_per_field = 4; |
| 4422 | const fields_per_u32 = 32 / bits_per_field; | 4424 | const fields_per_u32 = 32 / bits_per_field; |
| ... | @@ -4545,7 +4547,9 @@ pub fn analyzeUnionFields(mod: *Module, union_obj: *Union) InnerError!void { | ... | @@ -4545,7 +4547,9 @@ pub fn analyzeUnionFields(mod: *Module, union_obj: *Union) InnerError!void { |
| 4545 | }; | 4547 | }; |
| 4546 | defer assert(block.instructions.items.len == 0); // should all be comptime instructions | 4548 | defer assert(block.instructions.items.len == 0); // should all be comptime instructions |
| 4547 | 4549 | ||
| 4548 | _ = try sema.analyzeBody(&block, body); | 4550 | if (body.len != 0) { |
| 4551 | _ = try sema.analyzeBody(&block, body); | ||
| 4552 | } | ||
| 4549 | 4553 | ||
| 4550 | var auto_enum_tag: ?bool = null; | 4554 | var auto_enum_tag: ?bool = null; |
| 4551 | 4555 |
src/Sema.zig+6-8| ... | @@ -5425,11 +5425,8 @@ fn zirFieldType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr | ... | @@ -5425,11 +5425,8 @@ fn zirFieldType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr |
| 5425 | } | 5425 | } |
| 5426 | const struct_ty = try sema.resolveTypeFields(block, src, unresolved_struct_type); | 5426 | const struct_ty = try sema.resolveTypeFields(block, src, unresolved_struct_type); |
| 5427 | const struct_obj = struct_ty.castTag(.@"struct").?.data; | 5427 | const struct_obj = struct_ty.castTag(.@"struct").?.data; |
| 5428 | const field = struct_obj.fields.get(field_name) orelse { | 5428 | const field = struct_obj.fields.get(field_name) orelse |
| 5429 | return sema.mod.fail(&block.base, src, "no field named '{s}' in struct '{}'", .{ | 5429 | return sema.failWithBadFieldAccess(block, struct_obj, src, field_name); |
| 5430 | field_name, struct_ty, | ||
| 5431 | }); | ||
| 5432 | }; | ||
| 5433 | return sema.mod.constType(sema.arena, src, field.ty); | 5430 | return sema.mod.constType(sema.arena, src, field.ty); |
| 5434 | } | 5431 | } |
| 5435 | 5432 | ||
| ... | @@ -6220,13 +6217,14 @@ fn analyzeStructFieldPtr( | ... | @@ -6220,13 +6217,14 @@ fn analyzeStructFieldPtr( |
| 6220 | struct_ptr: *Inst, | 6217 | struct_ptr: *Inst, |
| 6221 | field_name: []const u8, | 6218 | field_name: []const u8, |
| 6222 | field_name_src: LazySrcLoc, | 6219 | field_name_src: LazySrcLoc, |
| 6223 | elem_ty: Type, | 6220 | unresolved_struct_ty: Type, |
| 6224 | ) InnerError!*Inst { | 6221 | ) InnerError!*Inst { |
| 6225 | const mod = sema.mod; | 6222 | const mod = sema.mod; |
| 6226 | const arena = sema.arena; | 6223 | const arena = sema.arena; |
| 6227 | assert(elem_ty.zigTypeTag() == .Struct); | 6224 | assert(unresolved_struct_ty.zigTypeTag() == .Struct); |
| 6228 | 6225 | ||
| 6229 | const struct_obj = elem_ty.castTag(.@"struct").?.data; | 6226 | const struct_ty = try sema.resolveTypeFields(block, src, unresolved_struct_ty); |
| 6227 | const struct_obj = struct_ty.castTag(.@"struct").?.data; | ||
| 6230 | 6228 | ||
| 6231 | const field_index = struct_obj.fields.getIndex(field_name) orelse | 6229 | const field_index = struct_obj.fields.getIndex(field_name) orelse |
| 6232 | return sema.failWithBadFieldAccess(block, struct_obj, field_name_src, field_name); | 6230 | return sema.failWithBadFieldAccess(block, struct_obj, field_name_src, field_name); |
test/stage2/cbe.zig+1-1| ... | @@ -516,7 +516,7 @@ pub fn addCases(ctx: *TestContext) !void { | ... | @@ -516,7 +516,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 516 | \\ return p.y - p.x - p.x; | 516 | \\ return p.y - p.x - p.x; |
| 517 | \\} | 517 | \\} |
| 518 | , &.{ | 518 | , &.{ |
| 519 | ":3:21: error: mising struct field: x", | 519 | ":3:21: error: missing struct field: x", |
| 520 | ":1:15: note: struct 'Point' declared here", | 520 | ":1:15: note: struct 'Point' declared here", |
| 521 | }); | 521 | }); |
| 522 | case.addError( | 522 | case.addError( |