ability to slice an undefined pointer at compile time if the len is 0

This commit is contained in:
Andrew Kelley
2018-02-16 15:22:29 -05:00
parent cbbd6cfa1e
commit 72ca2b214d
5 changed files with 63 additions and 27 deletions

View File

@@ -1,6 +1,13 @@
const tests = @import("tests.zig");
pub fn addCases(cases: &tests.CompileErrorContext) void {
cases.add("comptime slice of undefined pointer non-zero len",
\\export fn entry() void {
\\ const slice = (&i32)(undefined)[0..1];
\\}
,
".tmp_source.zig:2:36: error: non-zero length slice of undefined pointer");
cases.add("type checking function pointers",
\\fn a(b: fn (&const u8) void) void {
\\ b('a');