| author | |
| committer | |
| log | 38c161afabe1dc7d0df7ad981d70b962ef87120a |
| tree | f1944a2512b4567b2e35a0c2ac7b87c47c8d2cb7 |
| parent | c467f6693eb815906088b15f25d4e21092526bb4 |
3 files changed, 16 insertions(+), 12 deletions(-)
src/Sema.zig+10-8| ... | ... | @@ -7747,14 +7747,9 @@ fn zirHasDecl(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 7747 | 7747 | const container_type = try sema.resolveType(block, lhs_src, extra.lhs); |
| 7748 | 7748 | const decl_name = try sema.resolveConstString(block, rhs_src, extra.rhs); |
| 7749 | 7749 | |
| 7750 | // tuples are structs but they don't have a namespace | |
| 7751 | if (container_type.isTupleOrAnonStruct()) return Air.Inst.Ref.bool_false; | |
| 7752 | const namespace = container_type.getNamespace() orelse return sema.fail( | |
| 7753 | block, | |
| 7754 | lhs_src, | |
| 7755 | "expected struct, enum, union, or opaque, found '{}'", | |
| 7756 | .{container_type}, | |
| 7757 | ); | |
| 7750 | try checkNamespaceType(sema, block, lhs_src, container_type); | |
| 7751 | ||
| 7752 | const namespace = container_type.getNamespace() orelse return Air.Inst.Ref.bool_false; | |
| 7758 | 7753 | if (try sema.lookupInNamespace(block, src, namespace, decl_name, true)) |decl| { |
| 7759 | 7754 | if (decl.is_pub or decl.getFileScope() == block.getFileScope()) { |
| 7760 | 7755 | return Air.Inst.Ref.bool_true; |
| ... | ... | @@ -12882,6 +12877,13 @@ fn bitOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!u6 |
| 12882 | 12877 | } |
| 12883 | 12878 | } |
| 12884 | 12879 | |
| 12880 | fn checkNamespaceType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileError!void { | |
| 12881 | switch (ty.zigTypeTag()) { | |
| 12882 | .Struct, .Enum, .Union, .Opaque => return, | |
| 12883 | else => return sema.fail(block, src, "expected struct, enum, union, or opaque; found '{}'", .{ty}), | |
| 12884 | } | |
| 12885 | } | |
| 12886 | ||
| 12885 | 12887 | /// Returns `true` if the type was a comptime_int. |
| 12886 | 12888 | fn checkIntType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileError!bool { |
| 12887 | 12889 | switch (ty.zigTypeTag()) { |
test/behavior/switch.zig+5-1| ... | ... | @@ -631,7 +631,11 @@ test "switch on error set with single else" { |
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | test "switch capture copies its payload" { |
| 634 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO | |
| 634 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | |
| 635 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | |
| 636 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | |
| 637 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | |
| 638 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | |
| 635 | 639 | |
| 636 | 640 | const S = struct { |
| 637 | 641 | fn doTheTest() !void { |
test/behavior/union.zig+1-3| ... | ... | @@ -217,7 +217,7 @@ test "union with specified enum tag" { |
| 217 | 217 | comptime try doTest(); |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | test "packed union generates correctly aligned LLVM type" { | |
| 220 | test "packed union generates correctly aligned type" { | |
| 221 | 221 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 222 | 222 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 223 | 223 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| ... | ... | @@ -1104,8 +1104,6 @@ test "@unionInit on union with tag but no fields" { |
| 1104 | 1104 | } |
| 1105 | 1105 | |
| 1106 | 1106 | test "union enum type gets a separate scope" { |
| 1107 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO | |
| 1108 | ||
| 1109 | 1107 | const S = struct { |
| 1110 | 1108 | const U = union(enum) { |
| 1111 | 1109 | a: u8, |