mirror of
https://github.com/ziglang/zig.git
synced 2026-01-04 12:33:19 +00:00
add regression test case. closes #2980
This commit is contained in:
parent
9eed0d3603
commit
0c33ebb38e
@ -2,6 +2,25 @@ const tests = @import("tests.zig");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
cases.add(
|
||||
"regression test #2980: base type u32 is not type checked properly when assigning a value within a struct",
|
||||
\\const Foo = struct {
|
||||
\\ ptr: ?*usize,
|
||||
\\ uval: u32,
|
||||
\\};
|
||||
\\fn get_uval(x: u32) !u32 {
|
||||
\\ return error.NotFound;
|
||||
\\}
|
||||
\\export fn entry() void {
|
||||
\\ const afoo = Foo{
|
||||
\\ .ptr = null,
|
||||
\\ .uval = get_uval(42),
|
||||
\\ };
|
||||
\\}
|
||||
,
|
||||
"tmp.zig:11:25: error: expected type 'u32', found '@typeOf(get_uval).ReturnType.ErrorSet!u32'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"asigning to struct or union fields that are not optionals with a function that returns an optional",
|
||||
\\fn maybe(is: bool) ?u8 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user