-
-
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
Fix(sigmatch): allow varargs[T]
to accept overloaded symbol
#19475
Conversation
The current devel is failing CI so not sure if this break anything. Make merging quite difficult |
compiler/sigmatch.nim
Outdated
if userConvMatch(c, m, f, a, arg) == nil and f.kind == tyVarargs: | ||
if f.n == nil: | ||
if typeRel(m, base(f), a) == isGeneric: | ||
r = typeRel(m, base(f), a) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken from
Lines 2174 to 2182 in 33cd883
result = userConvMatch(c, m, f, a, arg) | |
# check for a base type match, which supports varargs[T] without [] | |
# constructor in a call: | |
if result == nil and f.kind == tyVarargs: | |
if f.n != nil: | |
# Forward to the varargs converter | |
result = localConvMatch(c, m, f, a, arg) | |
else: | |
r = typeRel(m, base(f), a) |
Could be more cases should be handled
Related: #19472 |
d6e8554
to
9d31112
Compare
I'm assuming this should be backported |
9d31112
to
abe0701
Compare
@@ -2258,6 +2263,9 @@ proc paramTypesMatch*(m: var TCandidate, f, a: PType, | |||
# See tsymchoice_for_expr as an example. 'f.kind == tyUntyped' should match | |||
# anyway: | |||
if f.kind in {tyUntyped, tyTyped}: result = arg | |||
elif m.calleeSym != nil and m.calleeSym.kind in {skMacro, skTemplate} and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likely caused by pre-existing code but the manual knows nothing about special casing overload resolution for macros and templates. So this is a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This basically copied from
Line 2061 in 33cd883
m.calleeSym.kind in {skMacro, skTemplate}: |
What are the semantics of a proc like
len
passed to a routine that isn't a macro or template?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well len
is a tyProc
. I don't understand the question I guess.
abe0701
to
0bc1c91
Compare
if userConvMatch(c, m, f, a, arg) == nil and f.kind == tyVarargs: | ||
if f.n == nil: | ||
let baseRel = typeRel(m, base(f), a) | ||
if baseRel == isGeneric: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should other cases be handled as well? When should it be a match but isn't isGeneric
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bump
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know.
There was a bug that params wouldn't be matched if the param was overloaded and the candidate type was varargs. This checks the base type of the `varargs` and then will to an overloaded symbol if in a macros or template. Fixes nim-lang#19446 & nim-lang#13913
This is only for macros as of now becasue I don't know what to do about non macro routines
d318fdb
to
8b1bc9f
Compare
I don't think the failure is related to this PR. |
I restarted the failed CI. The author can also restart CI without closing and reopening PRs => https://nim-lang.github.io/Nim/contributing.html#the-cmdgit-stuff-debugging-ci-failures-flaky-tests-etc |
Thanks |
This pull request has been automatically marked as stale because it has not had recent activity. If you think it is still a valid PR, please rebase it on the latest devel; otherwise it will be closed. Thank you for your contributions. |
This pull request has been marked as stale and closed due to inactivity after 395 days. |
Fix(sigmatch): allow
varargs[T]
to accept overloaded symbolThere was a bug that params wouldn't be matched if the param was overloaded and the candidate type was varargs. This checks the base type of the
varargs
and then will to an overloaded symbol if in a macros.I'm not sure what should be done in the case of a template.
There is a bug (which may be reported) of the following case:
which sems to the "first"
len
but not he right one because it's a closed choice sym.It is a separate issue, but it would now apply for a case of varargs also
Fixes #19446
Fixes #13913