| author | |
| committer | |
| log | f211c1559ab8c25a52d45e495ef42d4937e98e97 |
| tree | ade6e99d02bee14a5196ebb77e292242959aeb5d |
| parent | 8d66aacb64c17e0d36aca14642709e1cc542d67f |
| parent | a429f72ae80d748a860a7f812510399cfe80ed97 |
| signature |
Close more old stage1 issues13 files changed, 260 insertions(+), 4 deletions(-)
test/behavior.zig+9| ... | @@ -91,11 +91,19 @@ test { | ... | @@ -91,11 +91,19 @@ test { |
| 91 | _ = @import("behavior/bugs/11213.zig"); | 91 | _ = @import("behavior/bugs/11213.zig"); |
| 92 | _ = @import("behavior/bugs/11787.zig"); | 92 | _ = @import("behavior/bugs/11787.zig"); |
| 93 | _ = @import("behavior/bugs/11816.zig"); | 93 | _ = @import("behavior/bugs/11816.zig"); |
| 94 | _ = @import("behavior/bugs/11995.zig"); | ||
| 95 | _ = @import("behavior/bugs/12000.zig"); | ||
| 94 | _ = @import("behavior/bugs/12003.zig"); | 96 | _ = @import("behavior/bugs/12003.zig"); |
| 95 | _ = @import("behavior/bugs/12025.zig"); | 97 | _ = @import("behavior/bugs/12025.zig"); |
| 96 | _ = @import("behavior/bugs/12033.zig"); | 98 | _ = @import("behavior/bugs/12033.zig"); |
| 97 | _ = @import("behavior/bugs/12043.zig"); | 99 | _ = @import("behavior/bugs/12043.zig"); |
| 100 | _ = @import("behavior/bugs/12051.zig"); | ||
| 101 | _ = @import("behavior/bugs/12092.zig"); | ||
| 102 | _ = @import("behavior/bugs/12119.zig"); | ||
| 103 | _ = @import("behavior/bugs/12142.zig"); | ||
| 104 | _ = @import("behavior/bugs/12169.zig"); | ||
| 98 | _ = @import("behavior/bugs/12430.zig"); | 105 | _ = @import("behavior/bugs/12430.zig"); |
| 106 | _ = @import("behavior/bugs/12450.zig"); | ||
| 99 | _ = @import("behavior/bugs/12486.zig"); | 107 | _ = @import("behavior/bugs/12486.zig"); |
| 100 | _ = @import("behavior/bugs/12488.zig"); | 108 | _ = @import("behavior/bugs/12488.zig"); |
| 101 | _ = @import("behavior/bugs/12498.zig"); | 109 | _ = @import("behavior/bugs/12498.zig"); |
| ... | @@ -122,6 +130,7 @@ test { | ... | @@ -122,6 +130,7 @@ test { |
| 122 | _ = @import("behavior/bugs/13068.zig"); | 130 | _ = @import("behavior/bugs/13068.zig"); |
| 123 | _ = @import("behavior/bugs/13069.zig"); | 131 | _ = @import("behavior/bugs/13069.zig"); |
| 124 | _ = @import("behavior/bugs/13112.zig"); | 132 | _ = @import("behavior/bugs/13112.zig"); |
| 133 | _ = @import("behavior/bugs/13113.zig"); | ||
| 125 | _ = @import("behavior/bugs/13128.zig"); | 134 | _ = @import("behavior/bugs/13128.zig"); |
| 126 | _ = @import("behavior/bugs/13159.zig"); | 135 | _ = @import("behavior/bugs/13159.zig"); |
| 127 | _ = @import("behavior/bugs/13164.zig"); | 136 | _ = @import("behavior/bugs/13164.zig"); |
test/behavior/bugs/11995.zig created+34| ... | @@ -0,0 +1,34 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const testing = std.testing; | ||
| 3 | const builtin = @import("builtin"); | ||
| 4 | |||
| 5 | fn wuffs_base__make_io_buffer(arg_data: wuffs_base__slice_u8, arg_meta: *wuffs_base__io_buffer_meta) callconv(.C) void { | ||
| 6 | arg_data.ptr[0] = 'w'; | ||
| 7 | arg_meta.closed = false; | ||
| 8 | } | ||
| 9 | const wuffs_base__io_buffer_meta = extern struct { | ||
| 10 | wi: usize, | ||
| 11 | ri: usize, | ||
| 12 | pos: u64, | ||
| 13 | closed: bool, | ||
| 14 | }; | ||
| 15 | const wuffs_base__slice_u8 = extern struct { | ||
| 16 | ptr: [*c]u8, | ||
| 17 | len: usize, | ||
| 18 | }; | ||
| 19 | test { | ||
| 20 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | ||
| 21 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | ||
| 22 | if (builtin.zig_backend == .stage2_x86) return error.SkipZigTest; // TODO | ||
| 23 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | ||
| 24 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | ||
| 25 | var string: [5]u8 = "hello".*; | ||
| 26 | const arg_data = wuffs_base__slice_u8{ .ptr = @ptrCast([*c]u8, &string), .len = string.len }; | ||
| 27 | var arg_meta = wuffs_base__io_buffer_meta{ .wi = 1, .ri = 2, .pos = 3, .closed = true }; | ||
| 28 | wuffs_base__make_io_buffer(arg_data, &arg_meta); | ||
| 29 | try std.testing.expectEqualStrings("wello", arg_data.ptr[0..arg_data.len]); | ||
| 30 | try std.testing.expectEqual(@as(usize, 1), arg_meta.wi); | ||
| 31 | try std.testing.expectEqual(@as(usize, 2), arg_meta.ri); | ||
| 32 | try std.testing.expectEqual(@as(u64, 3), arg_meta.pos); | ||
| 33 | try std.testing.expect(!arg_meta.closed); | ||
| 34 | } | ||
test/behavior/bugs/12000.zig created+16| ... | @@ -0,0 +1,16 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const builtin = @import("builtin"); | ||
| 3 | |||
| 4 | const T = struct { | ||
| 5 | next: @TypeOf(null, @as(*const T, undefined)), | ||
| 6 | }; | ||
| 7 | |||
| 8 | test { | ||
| 9 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | ||
| 10 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | ||
| 11 | if (builtin.zig_backend == .stage2_x86) return error.SkipZigTest; // TODO | ||
| 12 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | ||
| 13 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | ||
| 14 | var t: T = .{ .next = null }; | ||
| 15 | try std.testing.expect(t.next == null); | ||
| 16 | } | ||
test/behavior/bugs/12051.zig created+39| ... | @@ -0,0 +1,39 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const builtin = @import("builtin"); | ||
| 3 | |||
| 4 | test { | ||
| 5 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | ||
| 6 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | ||
| 7 | if (builtin.zig_backend == .stage2_x86) return error.SkipZigTest; // TODO | ||
| 8 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | ||
| 9 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | ||
| 10 | const x = X{}; | ||
| 11 | try std.testing.expectEqual(@as(u16, 0), x.y.a); | ||
| 12 | try std.testing.expectEqual(false, x.y.b); | ||
| 13 | try std.testing.expectEqual(Z{ .a = 0 }, x.y.c); | ||
| 14 | try std.testing.expectEqual(Z{ .a = 0 }, x.y.d); | ||
| 15 | } | ||
| 16 | |||
| 17 | const X = struct { | ||
| 18 | y: Y = Y.init(), | ||
| 19 | }; | ||
| 20 | |||
| 21 | const Y = struct { | ||
| 22 | a: u16, | ||
| 23 | b: bool, | ||
| 24 | c: Z, | ||
| 25 | d: Z, | ||
| 26 | |||
| 27 | fn init() Y { | ||
| 28 | return .{ | ||
| 29 | .a = 0, | ||
| 30 | .b = false, | ||
| 31 | .c = @bitCast(Z, @as(u32, 0)), | ||
| 32 | .d = @bitCast(Z, @as(u32, 0)), | ||
| 33 | }; | ||
| 34 | } | ||
| 35 | }; | ||
| 36 | |||
| 37 | const Z = packed struct { | ||
| 38 | a: u32, | ||
| 39 | }; | ||
test/behavior/bugs/12092.zig created+28| ... | @@ -0,0 +1,28 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const builtin = @import("builtin"); | ||
| 3 | |||
| 4 | const Foo = struct { | ||
| 5 | a: Bar, | ||
| 6 | }; | ||
| 7 | |||
| 8 | const Bar = struct { | ||
| 9 | b: u32, | ||
| 10 | }; | ||
| 11 | |||
| 12 | fn takeFoo(foo: *const Foo) !void { | ||
| 13 | try std.testing.expectEqual(@as(u32, 24), foo.a.b); | ||
| 14 | } | ||
| 15 | |||
| 16 | test { | ||
| 17 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | ||
| 18 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | ||
| 19 | if (builtin.zig_backend == .stage2_x86) return error.SkipZigTest; // TODO | ||
| 20 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | ||
| 21 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | ||
| 22 | var baz: u32 = 24; | ||
| 23 | try takeFoo(&.{ | ||
| 24 | .a = .{ | ||
| 25 | .b = baz, | ||
| 26 | }, | ||
| 27 | }); | ||
| 28 | } | ||
test/behavior/bugs/12119.zig created+16| ... | @@ -0,0 +1,16 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const builtin = @import("builtin"); | ||
| 3 | |||
| 4 | const u8x32 = @Vector(32, u8); | ||
| 5 | const u32x8 = @Vector(8, u32); | ||
| 6 | |||
| 7 | test { | ||
| 8 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | ||
| 9 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | ||
| 10 | if (builtin.zig_backend == .stage2_x86) return error.SkipZigTest; // TODO | ||
| 11 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | ||
| 12 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | ||
| 13 | const zerox32: u8x32 = [_]u8{0} ** 32; | ||
| 14 | const bigsum: u32x8 = @bitCast(u32x8, zerox32); | ||
| 15 | try std.testing.expectEqual(0, @reduce(.Add, bigsum)); | ||
| 16 | } | ||
test/behavior/bugs/12142.zig created+37| ... | @@ -0,0 +1,37 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const builtin = @import("builtin"); | ||
| 3 | |||
| 4 | const Holder = struct { | ||
| 5 | array: []const u8, | ||
| 6 | }; | ||
| 7 | |||
| 8 | const Test = struct { | ||
| 9 | holders: []const Holder, | ||
| 10 | }; | ||
| 11 | |||
| 12 | const Letter = enum(u8) { | ||
| 13 | A = 0x41, | ||
| 14 | B, | ||
| 15 | }; | ||
| 16 | |||
| 17 | fn letter(e: Letter) u8 { | ||
| 18 | return @enumToInt(e); | ||
| 19 | } | ||
| 20 | |||
| 21 | test { | ||
| 22 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | ||
| 23 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | ||
| 24 | if (builtin.zig_backend == .stage2_x86) return error.SkipZigTest; // TODO | ||
| 25 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | ||
| 26 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | ||
| 27 | const test_struct = Test{ | ||
| 28 | .holders = &.{ | ||
| 29 | Holder{ | ||
| 30 | .array = &.{ | ||
| 31 | letter(.A), | ||
| 32 | }, | ||
| 33 | }, | ||
| 34 | }, | ||
| 35 | }; | ||
| 36 | try std.testing.expectEqualStrings("A", test_struct.holders[0].array); | ||
| 37 | } | ||
test/behavior/bugs/12169.zig created+14| ... | @@ -0,0 +1,14 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const builtin = @import("builtin"); | ||
| 3 | |||
| 4 | test { | ||
| 5 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | ||
| 6 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | ||
| 7 | if (builtin.zig_backend == .stage2_x86) return error.SkipZigTest; // TODO | ||
| 8 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | ||
| 9 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | ||
| 10 | const a = @Vector(2, bool){ true, true }; | ||
| 11 | const b = @Vector(1, bool){true}; | ||
| 12 | try std.testing.expect(@reduce(.And, a)); | ||
| 13 | try std.testing.expect(@reduce(.And, b)); | ||
| 14 | } | ||
test/behavior/bugs/12450.zig created+21| ... | @@ -0,0 +1,21 @@ | ||
| 1 | const expect = @import("std").testing.expect; | ||
| 2 | const builtin = @import("builtin"); | ||
| 3 | |||
| 4 | const Foo = packed struct { | ||
| 5 | a: i32, | ||
| 6 | b: u8, | ||
| 7 | }; | ||
| 8 | |||
| 9 | var buffer: [256]u8 = undefined; | ||
| 10 | |||
| 11 | test { | ||
| 12 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | ||
| 13 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | ||
| 14 | if (builtin.zig_backend == .stage2_x86) return error.SkipZigTest; // TODO | ||
| 15 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | ||
| 16 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | ||
| 17 | var f1: *align(16) Foo = @alignCast(16, @ptrCast(*align(1) Foo, &buffer[0])); | ||
| 18 | try expect(@typeInfo(@TypeOf(f1)).Pointer.alignment == 16); | ||
| 19 | try expect(@ptrToInt(f1) == @ptrToInt(&f1.a)); | ||
| 20 | try expect(@typeInfo(@TypeOf(&f1.a)).Pointer.alignment == 16); | ||
| 21 | } | ||
test/behavior/bugs/13113.zig created+21| ... | @@ -0,0 +1,21 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const builtin = @import("builtin"); | ||
| 3 | |||
| 4 | const Foo = extern struct { | ||
| 5 | a: u8 align(1), | ||
| 6 | b: u16 align(1), | ||
| 7 | }; | ||
| 8 | |||
| 9 | test { | ||
| 10 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | ||
| 11 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | ||
| 12 | if (builtin.zig_backend == .stage2_x86) return error.SkipZigTest; // TODO | ||
| 13 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | ||
| 14 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | ||
| 15 | const foo = Foo{ | ||
| 16 | .a = 1, | ||
| 17 | .b = 2, | ||
| 18 | }; | ||
| 19 | try std.testing.expectEqual(1, foo.a); | ||
| 20 | try std.testing.expectEqual(2, foo.b); | ||
| 21 | } | ||
test/cases/compile_errors/implicit_cast_const_array_to_mutable_slice.zig+7| ... | @@ -13,6 +13,11 @@ export fn entry2() void { | ... | @@ -13,6 +13,11 @@ export fn entry2() void { |
| 13 | const many: [*]u8 = str; | 13 | const many: [*]u8 = str; |
| 14 | _ = many; | 14 | _ = many; |
| 15 | } | 15 | } |
| 16 | export fn entry3() void { | ||
| 17 | const lang: []const u8 = "lang"; | ||
| 18 | const targets: [1][]const u8 = [_][]u8{lang}; | ||
| 19 | _ = targets; | ||
| 20 | } | ||
| 16 | 21 | ||
| 17 | // error | 22 | // error |
| 18 | // backend=stage2 | 23 | // backend=stage2 |
| ... | @@ -24,3 +29,5 @@ export fn entry2() void { | ... | @@ -24,3 +29,5 @@ export fn entry2() void { |
| 24 | // :8:27: note: cast discards const qualifier | 29 | // :8:27: note: cast discards const qualifier |
| 25 | // :13:25: error: expected type '[*]u8', found '*const [0:0]u8' | 30 | // :13:25: error: expected type '[*]u8', found '*const [0:0]u8' |
| 26 | // :13:25: note: cast discards const qualifier | 31 | // :13:25: note: cast discards const qualifier |
| 32 | // :18:44: error: expected type '[]u8', found '[]const u8' | ||
| 33 | // :18:44: note: cast discards const qualifier |
test/cases/compile_errors/invalid_store_to_comptime_field.zig+6| ... | @@ -61,6 +61,11 @@ pub export fn entry6() void { | ... | @@ -61,6 +61,11 @@ pub export fn entry6() void { |
| 61 | }; | 61 | }; |
| 62 | _ = State.init(false); | 62 | _ = State.init(false); |
| 63 | } | 63 | } |
| 64 | pub export fn entry7() void { | ||
| 65 | const list1 = .{ "sss", 1, 2, 3 }; | ||
| 66 | const list2 = @TypeOf(list1){ .@"0" = "xxx", .@"1" = 4, .@"2" = 5, .@"3" = 6 }; | ||
| 67 | _ = list2; | ||
| 68 | } | ||
| 64 | 69 | ||
| 65 | // error | 70 | // error |
| 66 | // target=native | 71 | // target=native |
| ... | @@ -73,4 +78,5 @@ pub export fn entry6() void { | ... | @@ -73,4 +78,5 @@ pub export fn entry6() void { |
| 73 | // :25:29: note: default value set here | 78 | // :25:29: note: default value set here |
| 74 | // :41:16: error: value stored in comptime field does not match the default value of the field | 79 | // :41:16: error: value stored in comptime field does not match the default value of the field |
| 75 | // :45:12: error: value stored in comptime field does not match the default value of the field | 80 | // :45:12: error: value stored in comptime field does not match the default value of the field |
| 81 | // :66:43: error: value stored in comptime field does not match the default value of the field | ||
| 76 | // :59:35: error: value stored in comptime field does not match the default value of the field | 82 | // :59:35: error: value stored in comptime field does not match the default value of the field |
test/cases/compile_errors/invalid_struct_field.zig+12-4| ... | @@ -1,15 +1,22 @@ | ... | @@ -1,15 +1,22 @@ |
| 1 | const A = struct { x : i32, }; | 1 | const A = struct { x: i32 }; |
| 2 | export fn f() void { | 2 | export fn f() void { |
| 3 | var a : A = undefined; | 3 | var a: A = undefined; |
| 4 | a.foo = 1; | 4 | a.foo = 1; |
| 5 | const y = a.bar; | 5 | const y = a.bar; |
| 6 | _ = y; | 6 | _ = y; |
| 7 | } | 7 | } |
| 8 | export fn g() void { | 8 | export fn g() void { |
| 9 | var a : A = undefined; | 9 | var a: A = undefined; |
| 10 | const y = a.bar; | 10 | const y = a.bar; |
| 11 | _ = y; | 11 | _ = y; |
| 12 | } | 12 | } |
| 13 | export fn e() void { | ||
| 14 | const B = struct { | ||
| 15 | fn f() void {} | ||
| 16 | }; | ||
| 17 | const b: B = undefined; | ||
| 18 | @import("std").debug.print("{}{}", .{ b.f, b.f }); | ||
| 19 | } | ||
| 13 | 20 | ||
| 14 | // error | 21 | // error |
| 15 | // backend=stage2 | 22 | // backend=stage2 |
| ... | @@ -18,4 +25,5 @@ export fn g() void { | ... | @@ -18,4 +25,5 @@ export fn g() void { |
| 18 | // :4:7: error: no field named 'foo' in struct 'tmp.A' | 25 | // :4:7: error: no field named 'foo' in struct 'tmp.A' |
| 19 | // :1:11: note: struct declared here | 26 | // :1:11: note: struct declared here |
| 20 | // :10:17: error: no field named 'bar' in struct 'tmp.A' | 27 | // :10:17: error: no field named 'bar' in struct 'tmp.A' |
| 21 | 28 | // :18:45: error: no field named 'f' in struct 'tmp.e.B' | |
| 29 | // :14:15: note: struct declared here |