authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-18 19:59:03-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-18 19:59:03-05:00
log0c33ebb38eeb383da62a8af8aa368e8f6cac63a2
tree6c9231918a2d19b3c3e990ba2be39a12f896273f
parent9eed0d3603c9ff04902e199ef358aba4bd7489f3
signaturelock-open Commit is signed but in an unrecognized format.

add regression test case. closes #2980


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 "regression test #2980: base type u32 is not type checked properly when assigning a value within a struct",
7 \\const Foo = struct {
8 \\ ptr: ?*usize,
9 \\ uval: u32,
10 \\};
11 \\fn get_uval(x: u32) !u32 {
12 \\ return error.NotFound;
13 \\}
14 \\export fn entry() void {
15 \\ const afoo = Foo{
16 \\ .ptr = null,
17 \\ .uval = get_uval(42),
18 \\ };
19 \\}
20 ,
21 "tmp.zig:11:25: error: expected type 'u32', found '@typeOf(get_uval).ReturnType.ErrorSet!u32'",
22 );
23
524 cases.add(
625 "asigning to struct or union fields that are not optionals with a function that returns an optional",
726 \\fn maybe(is: bool) ?u8 {