| ... | ... | @@ -2,6 +2,25 @@ const tests = @import("tests.zig"); |
| 2 | 2 | const builtin = @import("builtin"); |
| 3 | 3 | |
| 4 | 4 | pub 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 | |
| 5 | 24 | cases.add( |
| 6 | 25 | "asigning to struct or union fields that are not optionals with a function that returns an optional", |
| 7 | 26 | \\fn maybe(is: bool) ?u8 { |