Confusing on peer type resolution rules

The following switch expression fails to compile. In my current understanding, peer type resolution is to find a type all the peer values can coerce into. In the following example, it is obvious that all peer values can coerce into *const [1]u8, but the compiler denies it. Intended or bug? (If it is a bug, it is not worth being fixed.)

const print = @import("std").debug.print;

pub fn main() void {
    const x: u8 = 123;
    const ps = &x;
    print("{}\n", .{ @TypeOf(ps) }); // *const u8

    // Coercion from '*const u8' to '*const [1]u8' is supported.
    var p1a: *const [1]u8 = ps;
    _ = &p1a;
    
    // error: incompatible types: '*const u8' and '*const [1]u8'
    const p = switch (b) {
        true => ps,
        false => p1a,
    };
    _ = &p;
}
1 Like