| ... | @@ -6806,4 +6806,27 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -6806,4 +6806,27 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 6806 | , &[_][]const u8{ | 6806 | , &[_][]const u8{ |
| 6807 | "tmp.zig:2:27: error: type 'u32' does not support array initialization", | 6807 | "tmp.zig:2:27: error: type 'u32' does not support array initialization", |
| 6808 | }); | 6808 | }); |
| | 6809 | |
| | 6810 | cases.add("issue #2687: coerce from undefined array pointer to slice", |
| | 6811 | \\export fn foo1() void { |
| | 6812 | \\ const a: *[1]u8 = undefined; |
| | 6813 | \\ var b: []u8 = a; |
| | 6814 | \\} |
| | 6815 | \\export fn foo2() void { |
| | 6816 | \\ comptime { |
| | 6817 | \\ var a: *[1]u8 = undefined; |
| | 6818 | \\ var b: []u8 = a; |
| | 6819 | \\ } |
| | 6820 | \\} |
| | 6821 | \\export fn foo3() void { |
| | 6822 | \\ comptime { |
| | 6823 | \\ const a: *[1]u8 = undefined; |
| | 6824 | \\ var b: []u8 = a; |
| | 6825 | \\ } |
| | 6826 | \\} |
| | 6827 | , &[_][]const u8{ |
| | 6828 | "tmp.zig:3:19: error: use of undefined value here causes undefined behavior", |
| | 6829 | "tmp.zig:8:23: error: use of undefined value here causes undefined behavior", |
| | 6830 | "tmp.zig:14:23: error: use of undefined value here causes undefined behavior", |
| | 6831 | }); |
| 6809 | } | 6832 | } |