| ... | @@ -20,6 +20,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -20,6 +20,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 20 | break :x tc; | 20 | break :x tc; |
| 21 | }); | 21 | }); |
| 22 | | 22 | |
| | 23 | // Note: One of the error messages here is backwards. It would be nice to fix, but that's not |
| | 24 | // going to stop me from merging this branch which fixes a bunch of other stuff. |
| 23 | cases.add( | 25 | cases.add( |
| 24 | "incompatible sentinels", | 26 | "incompatible sentinels", |
| 25 | \\export fn entry1(ptr: [*:255]u8) [*:0]u8 { | 27 | \\export fn entry1(ptr: [*:255]u8) [*:0]u8 { |
| ... | @@ -40,8 +42,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -40,8 +42,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 40 | "tmp.zig:5:12: error: expected type '[*:0]u8', found '[*]u8'", | 42 | "tmp.zig:5:12: error: expected type '[*:0]u8', found '[*]u8'", |
| 41 | "tmp.zig:5:12: note: destination pointer requires a terminating '0' sentinel", | 43 | "tmp.zig:5:12: note: destination pointer requires a terminating '0' sentinel", |
| 42 | | 44 | |
| 43 | "tmp.zig:8:35: error: expected type '[2:0]u8', found '[2:255]u8'", | 45 | "tmp.zig:8:35: error: expected type '[2:255]u8', found '[2:0]u8'", |
| 44 | "tmp.zig:8:35: note: destination array requires a terminating '0' sentinel, but source array has a terminating '255' sentinel", | 46 | "tmp.zig:8:35: note: destination array requires a terminating '255' sentinel, but source array has a terminating '0' sentinel", |
| 45 | "tmp.zig:11:31: error: expected type '[2:0]u8', found '[2]u8'", | 47 | "tmp.zig:11:31: error: expected type '[2:0]u8', found '[2]u8'", |
| 46 | "tmp.zig:11:31: note: destination array requires a terminating '0' sentinel", | 48 | "tmp.zig:11:31: note: destination array requires a terminating '0' sentinel", |
| 47 | ); | 49 | ); |
| ... | @@ -96,32 +98,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -96,32 +98,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 96 | "tmp.zig:11:25: error: expected type 'u32', found '@typeOf(get_uval).ReturnType.ErrorSet!u32'", | 98 | "tmp.zig:11:25: error: expected type 'u32', found '@typeOf(get_uval).ReturnType.ErrorSet!u32'", |
| 97 | ); | 99 | ); |
| 98 | | 100 | |
| 99 | cases.add( | | |
| 100 | "function call assigned to incorrect type", | | |
| 101 | \\export fn entry() void { | | |
| 102 | \\ var arr: [4]f32 = undefined; | | |
| 103 | \\ arr = concat(); | | |
| 104 | \\} | | |
| 105 | \\fn concat() [16]f32 { | | |
| 106 | \\ return [1]f32{0}**16; | | |
| 107 | \\} | | |
| 108 | , | | |
| 109 | "tmp.zig:3:17: error: expected type '[4]f32', found '[16]f32'" | | |
| 110 | ); | | |
| 111 | | | |
| 112 | cases.add( | | |
| 113 | "generic function call assigned to incorrect type", | | |
| 114 | \\pub export fn entry() void { | | |
| 115 | \\ var res: []i32 = undefined; | | |
| 116 | \\ res = myAlloc(i32); | | |
| 117 | \\} | | |
| 118 | \\fn myAlloc(comptime arg: type) anyerror!arg{ | | |
| 119 | \\ unreachable; | | |
| 120 | \\} | | |
| 121 | , | | |
| 122 | "tmp.zig:3:18: error: expected type '[]i32', found 'anyerror!i32" | | |
| 123 | ); | | |
| 124 | | | |
| 125 | cases.add( | 101 | cases.add( |
| 126 | "asigning to struct or union fields that are not optionals with a function that returns an optional", | 102 | "asigning to struct or union fields that are not optionals with a function that returns an optional", |
| 127 | \\fn maybe(is: bool) ?u8 { | 103 | \\fn maybe(is: bool) ?u8 { |
| ... | @@ -205,7 +181,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -205,7 +181,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 205 | \\ var geo_data = getGeo3DTex2D(); | 181 | \\ var geo_data = getGeo3DTex2D(); |
| 206 | \\} | 182 | \\} |
| 207 | , | 183 | , |
| 208 | "tmp.zig:4:30: error: expected type '[][2]f32', found '[1][2]f32'", | 184 | "tmp.zig:4:30: error: array literal requires address-of operator to coerce to slice type '[][2]f32'", |
| 209 | ); | 185 | ); |
| 210 | | 186 | |
| 211 | cases.add( | 187 | cases.add( |
| ... | @@ -802,7 +778,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -802,7 +778,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 802 | \\ const x = []u8{1, 2}; | 778 | \\ const x = []u8{1, 2}; |
| 803 | \\} | 779 | \\} |
| 804 | , | 780 | , |
| 805 | "tmp.zig:2:15: error: expected array type or [_], found slice", | 781 | "tmp.zig:2:15: error: array literal requires address-of operator to coerce to slice type '[]u8'", |
| 806 | ); | 782 | ); |
| 807 | | 783 | |
| 808 | cases.add( | 784 | cases.add( |
| ... | @@ -811,7 +787,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -811,7 +787,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 811 | \\ const x = []u8{}; | 787 | \\ const x = []u8{}; |
| 812 | \\} | 788 | \\} |
| 813 | , | 789 | , |
| 814 | "tmp.zig:2:15: error: expected array type or [_], found slice", | 790 | "tmp.zig:2:15: error: array literal requires address-of operator to coerce to slice type '[]u8'", |
| 815 | ); | 791 | ); |
| 816 | | 792 | |
| 817 | cases.add( | 793 | cases.add( |
| ... | @@ -2310,8 +2286,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -2310,8 +2286,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2310 | \\ | 2286 | \\ |
| 2311 | \\fn bar(x: *b.Foo) void {} | 2287 | \\fn bar(x: *b.Foo) void {} |
| 2312 | , | 2288 | , |
| 2313 | "tmp.zig:6:9: error: expected type '*b.Foo', found '*a.Foo'", | 2289 | "tmp.zig:6:10: error: expected type '*b.Foo', found '*a.Foo'", |
| 2314 | "tmp.zig:6:9: note: pointer type child 'a.Foo' cannot cast into pointer type child 'b.Foo'", | 2290 | "tmp.zig:6:10: note: pointer type child 'a.Foo' cannot cast into pointer type child 'b.Foo'", |
| 2315 | "a.zig:1:17: note: a.Foo declared here", | 2291 | "a.zig:1:17: note: a.Foo declared here", |
| 2316 | "b.zig:1:17: note: b.Foo declared here", | 2292 | "b.zig:1:17: note: b.Foo declared here", |
| 2317 | ); | 2293 | ); |
| ... | @@ -4836,10 +4812,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -4836,10 +4812,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 4836 | "convert fixed size array to slice with invalid size", | 4812 | "convert fixed size array to slice with invalid size", |
| 4837 | \\export fn f() void { | 4813 | \\export fn f() void { |
| 4838 | \\ var array: [5]u8 = undefined; | 4814 | \\ var array: [5]u8 = undefined; |
| 4839 | \\ var foo = @bytesToSlice(u32, array)[0]; | 4815 | \\ var foo = @bytesToSlice(u32, &array)[0]; |
| 4840 | \\} | 4816 | \\} |
| 4841 | , | 4817 | , |
| 4842 | "tmp.zig:3:15: error: unable to convert [5]u8 to []align(1) const u32: size mismatch", | 4818 | "tmp.zig:3:15: error: unable to convert [5]u8 to []align(1) u32: size mismatch", |
| 4843 | "tmp.zig:3:29: note: u32 has size 4; remaining bytes: 1", | 4819 | "tmp.zig:3:29: note: u32 has size 4; remaining bytes: 1", |
| 4844 | ); | 4820 | ); |
| 4845 | | 4821 | |
| ... | @@ -5176,7 +5152,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -5176,7 +5152,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 5176 | \\ | 5152 | \\ |
| 5177 | \\export fn entry() usize { return @sizeOf(@typeOf(foo)); } | 5153 | \\export fn entry() usize { return @sizeOf(@typeOf(foo)); } |
| 5178 | , | 5154 | , |
| 5179 | "tmp.zig:8:16: error: expected type '*const u3', found '*align(:3:1) const u3'", | 5155 | "tmp.zig:8:26: error: expected type '*const u3', found '*align(:3:1) const u3'", |
| 5180 | ); | 5156 | ); |
| 5181 | | 5157 | |
| 5182 | cases.add( | 5158 | cases.add( |
| ... | @@ -5873,7 +5849,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -5873,7 +5849,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 5873 | \\ x.* += 1; | 5849 | \\ x.* += 1; |
| 5874 | \\} | 5850 | \\} |
| 5875 | , | 5851 | , |
| 5876 | "tmp.zig:8:9: error: expected type '*u32', found '*align(1) u32'", | 5852 | "tmp.zig:8:13: error: expected type '*u32', found '*align(1) u32'", |
| 5877 | ); | 5853 | ); |
| 5878 | | 5854 | |
| 5879 | cases.add( | 5855 | cases.add( |
| ... | @@ -5893,9 +5869,9 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -5893,9 +5869,9 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 5893 | \\ x[0] += 1; | 5869 | \\ x[0] += 1; |
| 5894 | \\} | 5870 | \\} |
| 5895 | , | 5871 | , |
| 5896 | "tmp.zig:9:9: error: cast increases pointer alignment", | 5872 | "tmp.zig:9:26: error: cast increases pointer alignment", |
| 5897 | "tmp.zig:9:26: note: '*align(1) u32' has alignment 1", | 5873 | "tmp.zig:9:26: note: '*align(1) u32' has alignment 1", |
| 5898 | "tmp.zig:9:9: note: '*[1]u32' has alignment 4", | 5874 | "tmp.zig:9:26: note: '*[1]u32' has alignment 4", |
| 5899 | ); | 5875 | ); |
| 5900 | | 5876 | |
| 5901 | cases.add( | 5877 | cases.add( |
| ... | @@ -6943,7 +6919,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -6943,7 +6919,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 6943 | \\ var foo: u32 = @This(){}; | 6919 | \\ var foo: u32 = @This(){}; |
| 6944 | \\} | 6920 | \\} |
| 6945 | , | 6921 | , |
| 6946 | "tmp.zig:2:27: error: expected type 'u32', found '(root)'", | 6922 | "tmp.zig:2:27: error: type 'u32' does not support array initialization", |
| 6947 | "tmp.zig:1:1: note: (root) declared here", | | |
| 6948 | ); | 6923 | ); |
| 6949 | } | 6924 | } |