| author | |
| committer | |
| log | 0a9d6956e7cac96c870ad062b4125b0a0a3b0143 |
| tree | 70a5516b83525fe000e8aa734852095a6cb99fb6 |
| parent | 6b36774adc407bc4c8271306410a20e13cbd55ad |
5 files changed, 21 insertions(+), 5 deletions(-)
lib/std/io/stream_source.zig-1| ... | @@ -114,7 +114,6 @@ test "StreamSource (mutable buffer)" { | ... | @@ -114,7 +114,6 @@ test "StreamSource (mutable buffer)" { |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | test "StreamSource (const buffer)" { | 116 | test "StreamSource (const buffer)" { |
| 117 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; | ||
| 118 | const buffer: [64]u8 = "Hello, World!".* ++ ([1]u8{0xAA} ** 51); | 117 | const buffer: [64]u8 = "Hello, World!".* ++ ([1]u8{0xAA} ** 51); |
| 119 | var source = StreamSource{ .const_buffer = std.io.fixedBufferStream(&buffer) }; | 118 | var source = StreamSource{ .const_buffer = std.io.fixedBufferStream(&buffer) }; |
| 120 | 119 |
lib/std/json.zig-1| ... | @@ -1355,7 +1355,6 @@ pub const Value = union(enum) { | ... | @@ -1355,7 +1355,6 @@ pub const Value = union(enum) { |
| 1355 | }; | 1355 | }; |
| 1356 | 1356 | ||
| 1357 | test "Value.jsonStringify" { | 1357 | test "Value.jsonStringify" { |
| 1358 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO | ||
| 1359 | { | 1358 | { |
| 1360 | var buffer: [10]u8 = undefined; | 1359 | var buffer: [10]u8 = undefined; |
| 1361 | var fbs = std.io.fixedBufferStream(&buffer); | 1360 | var fbs = std.io.fixedBufferStream(&buffer); |
lib/std/os/linux/io_uring.zig-2| ... | @@ -2154,7 +2154,6 @@ test "timeout (after a number of completions)" { | ... | @@ -2154,7 +2154,6 @@ test "timeout (after a number of completions)" { |
| 2154 | } | 2154 | } |
| 2155 | 2155 | ||
| 2156 | test "timeout_remove" { | 2156 | test "timeout_remove" { |
| 2157 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO | ||
| 2158 | if (builtin.os.tag != .linux) return error.SkipZigTest; | 2157 | if (builtin.os.tag != .linux) return error.SkipZigTest; |
| 2159 | 2158 | ||
| 2160 | var ring = IO_Uring.init(2, 0) catch |err| switch (err) { | 2159 | var ring = IO_Uring.init(2, 0) catch |err| switch (err) { |
| ... | @@ -2951,7 +2950,6 @@ test "provide_buffers: read" { | ... | @@ -2951,7 +2950,6 @@ test "provide_buffers: read" { |
| 2951 | } | 2950 | } |
| 2952 | 2951 | ||
| 2953 | test "remove_buffers" { | 2952 | test "remove_buffers" { |
| 2954 | if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO | ||
| 2955 | if (builtin.os.tag != .linux) return error.SkipZigTest; | 2953 | if (builtin.os.tag != .linux) return error.SkipZigTest; |
| 2956 | 2954 | ||
| 2957 | var ring = IO_Uring.init(1, 0) catch |err| switch (err) { | 2955 | var ring = IO_Uring.init(1, 0) catch |err| switch (err) { |
src/Sema.zig+3-1| ... | @@ -13757,10 +13757,10 @@ fn zirStructInit( | ... | @@ -13757,10 +13757,10 @@ fn zirStructInit( |
| 13757 | const field_type_extra = sema.code.extraData(Zir.Inst.FieldType, field_type_data.payload_index).data; | 13757 | const field_type_extra = sema.code.extraData(Zir.Inst.FieldType, field_type_data.payload_index).data; |
| 13758 | const field_name = sema.code.nullTerminatedString(field_type_extra.name_start); | 13758 | const field_name = sema.code.nullTerminatedString(field_type_extra.name_start); |
| 13759 | const field_index = try sema.unionFieldIndex(block, resolved_ty, field_name, field_src); | 13759 | const field_index = try sema.unionFieldIndex(block, resolved_ty, field_name, field_src); |
| 13760 | const tag_val = try Value.Tag.enum_field_index.create(sema.arena, field_index); | ||
| 13760 | 13761 | ||
| 13761 | const init_inst = try sema.resolveInst(item.data.init); | 13762 | const init_inst = try sema.resolveInst(item.data.init); |
| 13762 | if (try sema.resolveMaybeUndefVal(block, field_src, init_inst)) |val| { | 13763 | if (try sema.resolveMaybeUndefVal(block, field_src, init_inst)) |val| { |
| 13763 | const tag_val = try Value.Tag.enum_field_index.create(sema.arena, field_index); | ||
| 13764 | return sema.addConstantMaybeRef( | 13764 | return sema.addConstantMaybeRef( |
| 13765 | block, | 13765 | block, |
| 13766 | src, | 13766 | src, |
| ... | @@ -13779,6 +13779,8 @@ fn zirStructInit( | ... | @@ -13779,6 +13779,8 @@ fn zirStructInit( |
| 13779 | const alloc = try block.addTy(.alloc, alloc_ty); | 13779 | const alloc = try block.addTy(.alloc, alloc_ty); |
| 13780 | const field_ptr = try sema.unionFieldPtr(block, field_src, alloc, field_name, field_src, resolved_ty); | 13780 | const field_ptr = try sema.unionFieldPtr(block, field_src, alloc, field_name, field_src, resolved_ty); |
| 13781 | try sema.storePtr(block, src, field_ptr, init_inst); | 13781 | try sema.storePtr(block, src, field_ptr, init_inst); |
| 13782 | const new_tag = try sema.addConstant(resolved_ty.unionTagTypeHypothetical(), tag_val); | ||
| 13783 | _ = try block.addBinOp(.set_union_tag, alloc, new_tag); | ||
| 13782 | return alloc; | 13784 | return alloc; |
| 13783 | } | 13785 | } |
| 13784 | 13786 |
test/behavior/union.zig+18| ... | @@ -1183,3 +1183,21 @@ test "comptime equality of extern unions with same tag" { | ... | @@ -1183,3 +1183,21 @@ test "comptime equality of extern unions with same tag" { |
| 1183 | const b = S.U{ .a = 1234 }; | 1183 | const b = S.U{ .a = 1234 }; |
| 1184 | try expect(S.foo(a) == S.foo(b)); | 1184 | try expect(S.foo(a) == S.foo(b)); |
| 1185 | } | 1185 | } |
| 1186 | |||
| 1187 | test "union tag is set when initiated as a temporary value at runtime" { | ||
| 1188 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 1189 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | ||
| 1190 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | ||
| 1191 | |||
| 1192 | const U = union(enum) { | ||
| 1193 | a, | ||
| 1194 | b: u32, | ||
| 1195 | c, | ||
| 1196 | |||
| 1197 | fn doTheTest(u: @This()) !void { | ||
| 1198 | try expect(u == .b); | ||
| 1199 | } | ||
| 1200 | }; | ||
| 1201 | var b: u32 = 1; | ||
| 1202 | try (U{ .b = b }).doTheTest(); | ||
| 1203 | } |