Relax 'Cannot use a polymorphic type for a compound literal' restriction to support the use of more flexible wrapper types. #6021
Closed
JesseRMeyer
started this conversation in
Ideas/Requests
Replies: 1 comment
-
|
gB has designated this limitation as a bug on Discord. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I propose that the limitation: Error: Cannot use a polymorphic type for a compound literal, got '$Q'
to be lifted, to allow for constructions like:
Where $Q may resemble (in addition to supporting procedures like Pop):
Lifting this restriction allows for relatively seamless wrapper types that leverage preexisting duck-typing parapoly functionality. Otherwise this is simply a hard restriction on the composition capabilities of Odin. As it stands, the wrapping type ThreadSafeQueue has no way to know what type to provide as a return type (or an an input parameter for Put). Type erasure is an option but it shouldn't be the only one.
My hope is that the error exists as a preventative measure that can be relaxed as opposed to a design goal.
Beta Was this translation helpful? Give feedback.
All reactions