Open MarkMcCulloh opened 2 months ago
Right now Wing treats struct types "nominatively" where the type is part of its identity, so this isn't a bug. In the language reference it mentions
Two structs are equal if they have the same type and all of their fields are equal (based on rules of equality of their type).
There are tradeoffs to both kinds of type systems
Fair, forgot to reference the language ref.
There are tradeoffs to both kinds of type systems
Of course, but I feel like we've already made the choice to treat structs as structurally typed in some cases e.g. struct expansion and Json casting. No real reason to not give the same benefit to named structs as far as I can tell.
I tried this:
This happened:
Compilation error (
Expected type to be "A", but got "B" instead
)I expected this:
No error. B structural satisfies A, which should be good enough for structs
Anything else?
This should work with the same logic as struct expansion
Community Notes