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
I'm not sure this is a bug. It's probably harmless, but it seems wrong.
constEmptyStruct=struct {};
fnfunc(es: *EmptyStruct) void {}
test"" {
vares=EmptyStruct {};
func(es); // this ought to be `func(&es);`varesp: *EmptyStruct=es; // also compiles fine for some reason
}
If the struct has fields, it is an error.
The text was updated successfully, but these errors were encountered:
Types that have only 1 possible value have no address, and pointers to them are zero bit types themselves. Implicitly casting a value which has only 1 possible value to a mutable pointer of it is allowed since it's safe and has an obvious result.
I don't remember the motivation for this, but it's not just academic - there was something that implementing this solved and made cleaner in the compiler.
Ok. It does seem really particular that this is the only situation where incompatible-seeming types are allowed to coerce. *EmptyStruct to EmptyStruct doesn't compile, neither does any combination of two different structs (e.g. EmptyStruct to *AnotherEmptyStruct), nor a struct and another zero-bit type like u0.
I'm not sure this is a bug. It's probably harmless, but it seems wrong.
If the struct has fields, it is an error.
The text was updated successfully, but these errors were encountered: