add compile error for incompatible pointer sentinels
This commit is contained in:
@@ -2,6 +2,21 @@ const tests = @import("tests.zig");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
cases.add(
|
||||
"incompatible pointer sentinels",
|
||||
\\export fn entry1(ptr: [*:255]u8) [*:0]u8 {
|
||||
\\ return ptr;
|
||||
\\}
|
||||
\\export fn entry2(ptr: [*]u8) [*:0]u8 {
|
||||
\\ return ptr;
|
||||
\\}
|
||||
,
|
||||
"tmp.zig:2:5: error: expected type '[*:0]u8', found '[*:255]u8'",
|
||||
"tmp.zig:2:5: note: destination pointer requires a terminating '0' sentinel value, but source pointer has a terminating '255' sentinel value",
|
||||
"tmp.zig:5:5: error: expected type '[*:0]u8', found '[*]u8'",
|
||||
"tmp.zig:5:5: note: destination pointer requires a terminating '0' sentinel value",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"regression test #2980: base type u32 is not type checked properly when assigning a value within a struct",
|
||||
\\const Foo = struct {
|
||||
|
||||
Reference in New Issue
Block a user