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 suspect this has something to do with how object literal ASTs get expanded in the expr pass, then "caught up" by running prior passes. I suspect that in the process of catching up, there is confusion about type parameter name scoping.
Needs more investigation to get a more concrete take on what's going on.
SeanTAllen
changed the title
Name clashes in object literals?
Generic parameter when copying a trait method into an object that has a generic parameter of the same name
Oct 10, 2023
This is not due to the object literal expansion as I thought in my previous comment, and it's not quite as obvious as being a bug (though it is super unfortunate). It's a surprising limitation.
In the short term, @SeanTAllen wants to add documentation warning about this limitation.
In the long term, the way to fix this would be to change how we copy trait methods into the type that "inherits" them, to rewrite type parameter names to be hygienic.
That would avoid the clash between the Into type parameter that the object literal is using, and the Into type parameter on the into` function that gets copied in.
This code won't compile:
(The reason I am using a
Converter
primitive and not directly an object literal is #4451)But this will do, just changing the name of the
Into
type (and only that) into any other name (here,Dest
):The text was updated successfully, but these errors were encountered: