authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-18 17:31:35-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-18 17:31:35-05:00
log21aed86a4a33b51857d82e4d8ed12ba3d4183de2
treeb30d3fc798e2dfb325d8c136392fc2fa63b5bedc
parent4dd3f429724768d575e297a82d633b4016467e72
signaturelock-open Commit is signed but in an unrecognized format.

add regression test case

closes #3097

1 files changed, 19 insertions(+), 0 deletions(-)

test/compile_errors.zig+19
......@@ -2,6 +2,25 @@ const tests = @import("tests.zig");
22const builtin = @import("builtin");
33
44pub fn addCases(cases: *tests.CompileErrorContext) void {
5 cases.add(
6 "asigning to struct or union fields that are not optionals with a function that returns an optional",
7 \\fn maybe(is: bool) ?u8 {
8 \\ if (is) return @as(u8, 10) else return null;
9 \\}
10 \\const U = union {
11 \\ Ye: u8,
12 \\};
13 \\const S = struct {
14 \\ num: u8,
15 \\};
16 \\export fn entry() void {
17 \\ var u = U{ .Ye = maybe(false) };
18 \\ var s = S{ .num = maybe(false) };
19 \\}
20 ,
21 "tmp.zig:11:27: error: expected type 'u8', found '?u8'",
22 );
23
524 cases.add(
625 "missing result type for phi node",
726 \\fn foo() !void {