From 90598b4631e3b68565c7d62102a9e4615514a721 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 28 Feb 2018 00:51:22 +0100 Subject: fix assert on self-referencing function ptr field The construct `struct S { f: fn(S) void }` is not legal because structs are not copyable but it should not result in an ICE. Fixes #795. --- test/compile_errors.zig | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/compile_errors.zig') diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 940125711b..a3ac4e2344 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -3090,4 +3090,16 @@ pub fn addCases(cases: &tests.CompileErrorContext) void { , ".tmp_source.zig:11:20: error: runtime cast to union 'Value' which has non-void fields", ".tmp_source.zig:3:5: note: field 'A' has type 'i32'"); + + cases.add("self-referencing function pointer field", + \\const S = struct { + \\ f: fn(_: S) void, + \\}; + \\fn f(_: S) void { + \\} + \\export fn entry() void { + \\ var _ = S { .f = f }; + \\} + , + ".tmp_source.zig:4:9: error: type 'S' is not copyable; cannot pass by value"); } -- cgit v1.2.3