From 72ca2b214d4ffbaeed4840a806fb63740cf13c05 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 16 Feb 2018 15:22:29 -0500 Subject: ability to slice an undefined pointer at compile time if the len is 0 --- test/compile_errors.zig | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/compile_errors.zig') diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 90b3ff023a..940125711b 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -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'); -- cgit v1.2.3