| author | |
| committer | |
| log | 2ce5f84c2f2ca5470e34194d853d6950f42cf0e8 |
| tree | d9ca01166ba32ac7e98a2218fda8d75946f8cd0f |
| parent | 05265160ae7a43a1dd15a061138501621cf1da3d |
See #20182 files changed, 11 insertions(+), 1 deletions(-)
src/stage1/ir.cpp+1-1| ... | ... | @@ -17778,7 +17778,7 @@ static bool is_pointer_arithmetic_allowed(ZigType *lhs_type, IrBinOp op) { |
| 17778 | 17778 | return false; |
| 17779 | 17779 | switch (lhs_type->data.pointer.ptr_len) { |
| 17780 | 17780 | case PtrLenSingle: |
| 17781 | return lhs_type->data.pointer.child_type->id == ZigTypeIdArray; | |
| 17781 | return false; | |
| 17782 | 17782 | case PtrLenUnknown: |
| 17783 | 17783 | case PtrLenC: |
| 17784 | 17784 | return true; |
test/compile_errors.zig+10| ... | ... | @@ -2,6 +2,16 @@ const tests = @import("tests.zig"); |
| 2 | 2 | const std = @import("std"); |
| 3 | 3 | |
| 4 | 4 | pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 5 | cases.add("pointer arithmetic on pointer-to-array", | |
| 6 | \\export fn foo() void { | |
| 7 | \\ var x: [10]u8 = undefined; | |
| 8 | \\ var y = &x; | |
| 9 | \\ var z = y + 1; | |
| 10 | \\} | |
| 11 | , &[_][]const u8{ | |
| 12 | "tmp.zig:4:17: error: integer value 1 cannot be coerced to type '*[10]u8'", | |
| 13 | }); | |
| 14 | ||
| 5 | 15 | cases.add("@Type() union payload is undefined", |
| 6 | 16 | \\const Foo = @Type(@import("std").builtin.TypeInfo{ |
| 7 | 17 | \\ .Struct = undefined, |