mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
stage 1: improve error message if error union is cast to payload (#10770)
Also: Added special error message for for `?T` to `T` casting
This commit is contained in:
@@ -790,9 +790,9 @@ pub fn addCases(ctx: *TestContext) !void {
|
||||
"tmp.zig:1:17: note: function cannot return an error",
|
||||
"tmp.zig:8:5: error: expected type 'void', found '@typeInfo(@typeInfo(@TypeOf(bar)).Fn.return_type.?).ErrorUnion.error_set'",
|
||||
"tmp.zig:7:17: note: function cannot return an error",
|
||||
"tmp.zig:11:15: error: expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(bar)).Fn.return_type.?).ErrorUnion.error_set!u32'",
|
||||
"tmp.zig:11:15: error: cannot convert error union to payload type. consider using `try`, `catch`, or `if`. expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(bar)).Fn.return_type.?).ErrorUnion.error_set!u32'",
|
||||
"tmp.zig:10:17: note: function cannot return an error",
|
||||
"tmp.zig:15:14: error: expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(bar)).Fn.return_type.?).ErrorUnion.error_set!u32'",
|
||||
"tmp.zig:15:14: error: cannot convert error union to payload type. consider using `try`, `catch`, or `if`. expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(bar)).Fn.return_type.?).ErrorUnion.error_set!u32'",
|
||||
"tmp.zig:14:5: note: cannot store an error in type 'u32'",
|
||||
});
|
||||
|
||||
@@ -1879,7 +1879,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
||||
\\ _ = afoo;
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:12:25: error: expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(get_uval)).Fn.return_type.?).ErrorUnion.error_set!u32'",
|
||||
"tmp.zig:12:25: error: cannot convert error union to payload type. consider using `try`, `catch`, or `if`. expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(get_uval)).Fn.return_type.?).ErrorUnion.error_set!u32'",
|
||||
});
|
||||
|
||||
ctx.objErrStage1("assigning to struct or union fields that are not optionals with a function that returns an optional",
|
||||
@@ -1899,7 +1899,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
||||
\\ _ = s;
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:11:27: error: expected type 'u8', found '?u8'",
|
||||
"tmp.zig:11:27: error: cannot convert optional to payload type. consider using `.?`, `orelse`, or `if`. expected type 'u8', found '?u8'",
|
||||
});
|
||||
|
||||
ctx.objErrStage1("missing result type for phi node",
|
||||
@@ -2308,7 +2308,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
||||
\\ not_optional: i32,
|
||||
\\};
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:3:36: error: expected type 'i32', found '?i32'",
|
||||
"tmp.zig:3:36: error: cannot convert optional to payload type. consider using `.?`, `orelse`, or `if`. expected type 'i32', found '?i32'",
|
||||
});
|
||||
|
||||
ctx.objErrStage1("result location incompatibility mismatching handle_is_ptr",
|
||||
@@ -2325,7 +2325,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
||||
\\ not_optional: i32,
|
||||
\\};
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:3:36: error: expected type 'i32', found '?i32'",
|
||||
"tmp.zig:3:36: error: cannot convert optional to payload type. consider using `.?`, `orelse`, or `if`. expected type 'i32', found '?i32'",
|
||||
});
|
||||
|
||||
ctx.objErrStage1("const frame cast to anyframe",
|
||||
@@ -8828,7 +8828,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
||||
\\ v = u;
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:4:9: error: expected type '*anyopaque', found '?*anyopaque'",
|
||||
"tmp.zig:4:9: error: cannot convert optional to payload type. consider using `.?`, `orelse`, or `if`. expected type '*anyopaque', found '?*anyopaque'",
|
||||
});
|
||||
|
||||
ctx.objErrStage1("Issue #6823: don't allow .* to be followed by **",
|
||||
|
||||
Reference in New Issue
Block a user