Closed
Description
Zig Version
0.10.0-dev.1958+d5fcb5098
Steps to Reproduce
Here is the minimal reproducible example:
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.
^