You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const err = error {SomeError};
fn testFunction() err![]const u8 {
return err.SomeError;
}
pub fn main() void {
var result = testFunction() catch "replacement"; // ← type coercion works in a normal variable
var tuple = .{testFunction() catch "replacement"}; // ← but doesn't work for a tuple.
_ = tuple;
_ = result;
}
Expected Behavior
The string literal after the catch should coerce to the returning type of the function: []const u8.
Actual Behavior
Type coercion works fine for the normal variable, but with the tuple there is a compiler error:
./mre.zig:9:33: error: expected type '*const [11:0]u8', found '[]const u8'
var tuple = .{testFunction() catch "replacement"}; // ← but doesn't work for a tuple.
^
The text was updated successfully, but these errors were encountered:
Zig Version
0.10.0-dev.1958+d5fcb5098
Steps to Reproduce
Here is the minimal reproducible example:
Expected Behavior
The string literal after the
catch
should coerce to the returning type of the function:[]const u8
.Actual Behavior
Type coercion works fine for the normal variable, but with the tuple there is a compiler error:
The text was updated successfully, but these errors were encountered: