diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-09-08 03:59:38 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-08 03:59:38 -0700 |
| commit | 05cff8a558fda0e974ea7d00f26f8f4ff6e1195f (patch) | |
| tree | c99a4d2366532e5937ca7f944eb0008601a4edce /test | |
| parent | 426d65d700012b27ffa652258554032f171ad77d (diff) | |
| parent | 7666d5fc2653023670f6e61b6d19b0ba15750d67 (diff) | |
| download | zig-05cff8a558fda0e974ea7d00f26f8f4ff6e1195f.tar.gz zig-05cff8a558fda0e974ea7d00f26f8f4ff6e1195f.zip | |
Merge pull request #25186 from ziglang/vector-memory-coercion
frontend: vectors and arrays no longer support in-memory coercion
Diffstat (limited to 'test')
| -rw-r--r-- | test/behavior/cast.zig | 1 | ||||
| -rw-r--r-- | test/behavior/union.zig | 6 | ||||
| -rw-r--r-- | test/behavior/vector.zig | 1 | ||||
| -rw-r--r-- | test/cases/compile_errors/in_memory_coerce_vector_to_array.zig | 16 |
4 files changed, 23 insertions, 1 deletions
diff --git a/test/behavior/cast.zig b/test/behavior/cast.zig index 7eee20e3e0..700bfb0991 100644 --- a/test/behavior/cast.zig +++ b/test/behavior/cast.zig @@ -1737,6 +1737,7 @@ test "peer type resolution: array and vector with same child type" { if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; var arr: [2]u32 = .{ 0, 1 }; var vec: @Vector(2, u32) = .{ 2, 3 }; diff --git a/test/behavior/union.zig b/test/behavior/union.zig index 1807cf14cf..d581d25a1a 100644 --- a/test/behavior/union.zig +++ b/test/behavior/union.zig @@ -103,7 +103,11 @@ test "basic extern unions" { var foo = FooExtern{ .int = 1 }; try expect(foo.int == 1); foo.str.slice = "Well"; - try expect(std.mem.eql(u8, std.mem.sliceTo(foo.str.slice, 0), "Well")); + try expect(foo.str.slice[0] == 'W'); + try expect(foo.str.slice[1] == 'e'); + try expect(foo.str.slice[2] == 'l'); + try expect(foo.str.slice[3] == 'l'); + try expect(foo.str.slice[4] == 0); } const ExternPtrOrInt = extern union { diff --git a/test/behavior/vector.zig b/test/behavior/vector.zig index 3012830079..4de7c42d49 100644 --- a/test/behavior/vector.zig +++ b/test/behavior/vector.zig @@ -196,6 +196,7 @@ test "array to vector" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; const S = struct { fn doTheTest() !void { diff --git a/test/cases/compile_errors/in_memory_coerce_vector_to_array.zig b/test/cases/compile_errors/in_memory_coerce_vector_to_array.zig new file mode 100644 index 0000000000..59ecf149dc --- /dev/null +++ b/test/cases/compile_errors/in_memory_coerce_vector_to_array.zig @@ -0,0 +1,16 @@ +export fn entry() void { + _ = foo() catch {}; +} +fn foo() anyerror![4]u32 { + return bar(); +} +fn bar() anyerror!@Vector(4, u32) { + return .{ 1, 2, 3, 4 }; +} +// error +// backend=stage2 +// target=native +// +// :5:15: error: expected type 'anyerror![4]u32', found 'anyerror!@Vector(4, u32)' +// :5:15: note: error union payload '@Vector(4, u32)' cannot cast into error union payload '[4]u32' +// :4:18: note: function return type declared here |
