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
{{ message }}
Repository navigation
Wrong type inferred for indirect call of generic function #29638
functioncall<P1,R>(f: (p1: P1)=>R,p1: P1): R{returnf(p1);}functionidentity<T>(o: T): T{returno;}constx=call(identity,1);// When the parameters are reversed, it works:functioncallReversed<P1,R>(p1: P1,f: (p1: P1)=>R): R{returnf(p1);}consty=callReversed(1,identity);
We don't do full unification - we match parameters from left to right (which is why reversing the order fixes the issue). It's a known design limitation - we've talked about improving it before (you can probably find related discussions by searching for topics about higher order functions).
Timm Preetz (@tp) Issues are closed if there isn't an identifiable next set of work to do. In this case, we believe the only next step would be a near-complete rewrite of generic inference, which is already tracked at #30134.
Activity
weswigham commentedon Jan 29, 2019
We don't do full unification - we match parameters from left to right (which is why reversing the order fixes the issue). It's a known design limitation - we've talked about improving it before (you can probably find related discussions by searching for topics about higher order functions).
tp commentedon Mar 5, 2019
Would this also be fixed by #30215?
Edit: Ah, I guess not, because that PR states:
Indeed this won't be supported yet with that change: #30215 (comment)
tp commentedon Mar 5, 2019
Ryan Cavanaugh (@RyanCavanaugh) Why did you close this if the reported issue still persists?
RyanCavanaugh commentedon Mar 5, 2019
Timm Preetz (@tp) Issues are closed if there isn't an identifiable next set of work to do. In this case, we believe the only next step would be a near-complete rewrite of generic inference, which is already tracked at #30134.
ahejlsberg commentedon Mar 6, 2019
Actually, this issue is fixed with the latest commits in #30215.