commit a33b9aec724dfce68889f6255a2c78572b47c92f (tree)
parent ca2a788a240bbc3fa8060471bcda845e543dac70
Author: Andrew Kelley <andrew@ziglang.org>
Date: Mon, 11 Nov 2019 18:01:27 -0500
add test for missing const in slice with nested array type
Diffstat:
1 file changed, 17 insertions(+), 0 deletions(-)
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
@@ -3,6 +3,23 @@ const builtin = @import("builtin");
pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add(
+ "missing const in slice with nested array type",
+ \\const Geo3DTex2D = struct { vertices: [][2]f32 };
+ \\pub fn getGeo3DTex2D() Geo3DTex2D {
+ \\ return Geo3DTex2D{
+ \\ .vertices = [_][2]f32{
+ \\ [_]f32{ -0.5, -0.5},
+ \\ },
+ \\ };
+ \\}
+ \\export fn entry() void {
+ \\ var geo_data = getGeo3DTex2D();
+ \\}
+ ,
+ "tmp.zig:4:30: error: expected type '[][2]f32', found '[1][2]f32'",
+ );
+
+ cases.add(
"slicing of global undefined pointer",
\\var buf: *[1]u8 = undefined;
\\export fn entry() void {