Decl literals and packed struct equality

Extend decl literals to work with packed struct equality
i.e if (vec == .zero)
It’s just weird that they don’t work here

Would be particularly nice with switch on packed structs

3 Likes

i suspect that the “problem” here is that expressions like a == b are subject to a different form of type resolution than you’re holding in your head: in particular, T == @Type(.enum_literal) doesn’t automatically attempt to cast the RHS to be of type T

Yes, what’s happening here is peer type resolution instead of result location semantics, I’m not surprised that it doesn’t work.
But I think it’s reasonable to have

I wouldn’t be surprised if it just works for switches when that gets implemented. In which case, it would be even weirder that it doesn’t work with ==

2 Likes

Just found out packed == .{...} doesn’t work either, should be the same issue as with decl literals.