mirror of
https://github.com/ziglang/zig.git
synced 2026-01-21 06:45:24 +00:00
parent
fd18252a71
commit
afaef36194
@ -17841,7 +17841,7 @@ static bool is_pointer_arithmetic_allowed(ZigType *lhs_type, IrBinOp op) {
|
||||
return false;
|
||||
switch (lhs_type->data.pointer.ptr_len) {
|
||||
case PtrLenSingle:
|
||||
return lhs_type->data.pointer.child_type->id == ZigTypeIdArray;
|
||||
return false;
|
||||
case PtrLenUnknown:
|
||||
case PtrLenC:
|
||||
return true;
|
||||
|
||||
@ -2,6 +2,16 @@ const tests = @import("tests.zig");
|
||||
const std = @import("std");
|
||||
|
||||
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
cases.add("pointer arithmetic on pointer-to-array",
|
||||
\\export fn foo() void {
|
||||
\\ var x: [10]u8 = undefined;
|
||||
\\ var y = &x;
|
||||
\\ var z = y + 1;
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:4:17: error: integer value 1 cannot be coerced to type '*[10]u8'",
|
||||
});
|
||||
|
||||
cases.add("@Type() union payload is undefined",
|
||||
\\const Foo = @Type(@import("std").builtin.TypeInfo{
|
||||
\\ .Struct = undefined,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user