-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.
Milestone
Description
Zig Version
0.10.1
Steps to Reproduce and Observed Behavior
Coercing from a homogeneous tuple to an array works as it should. However, peer type resolution between the two same types will fail.
const std = @import("std");
test {
const x: [8]i16 = .{ 1, 2, 3, 4, 5, 6, 7, 8 };
const y = .{ 1, 2, 3, 4, 5, 6, 7, 8 };
const a = @as(@TypeOf(x), y); // This passes, as it should. (Tuple coerced to array)
const T = @TypeOf(x, y); // This fails
const b = (x == y); // This also fails
_ = a; _ = T; _ = b;
}This appears to contradict this line in the documentation: This kind of type resolution chooses a type that all peer types can coerce into. Both the types coerce into the array, thus the peer type resolution should succeed.
Side question: Is there a reason an array can't coerce into a tuple?
Expected Behavior
In the above example, @TypeOf(x,y) should give [8]i16.
Metadata
Metadata
Assignees
Labels
enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.