-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generic instantiation breaks template with untyped parameter overload resolution depending upon import order #19323
Comments
This is simply the good old "you cannot overload routines that use |
Ok. Thanks for the quick reply. Maybe some more related issues cross-linked might help other bug searchers, although now that I know exactly what to look for there seem like dozens of these issues:
I'll also edit the title to include overload resolution. |
This is not nim-lang/RFCs#402, the issue is generics thinking |
As mentioned by the EDIT in top post, the above works with either |
Generics do not semcheck arguments of symbols where the first discovered overload is a template or macro with completely untyped arguments. That's why the import order changes it |
Just since the linked issue suggests this workaround, in this case changing to template sum*(F: typedesc[SomeNumber], i, itr, expr): untyped = does not fix the problem / alter behavior. |
Example
Current Output
With
-d:fail
Expected Output
Without -d:fail
Additional Information
but I do not think the version matters much. It fails & works the same way on Nim from 0.19.2 to present day devel (0.20.2, 1.4, 1.6, etc). I also had someone else test it on their Nim build. So, the failure seems to be robust/reproducible.
isMainModule
is unneeded to fail|work; Just to check/provide some correct output. (Someone could maybe do an exponentially expanding search of past git versions to see if it ever worked and if sogit bisect
to see what broke things.)Things that do not alter the fail to compile|work pattern in the above mentioned versions:
for i in itr
to avar i = 0; while i <= limit
loopdef2
orfoo
genericThings that do alter the fail|work pattern:
from bsum import nil; from asum import nil
with module-qualified name reference always works (i.e. in either b,a or a,b order).sum*[F](i, itr, expr): untyped
sum*(F, i, ..)
tosum*(F, i: typed{nkSym}, ..)
This may relate to #13572 & #16128 , but it may also be its own thing. I could not find any other related issues, but maybe someone else can. Note that both the kind of routine for
sum
and the parameter count vary (and node kind constraints withi: typed{nkSym}
). So, if it is caching then something may be causing the "keys" for the cache to not include any signature information.Users sometimes
import
enough modules that even finding a working permutation might be intractable for frequent overloads likeadd
. So, this would seem a high priority bug to me.The text was updated successfully, but these errors were encountered: