-
-
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
varargs forwarding doesn't work properly when the target proc has default params #9996
Comments
Currently |
The use case here is heterogeneous varargs and perfect argument forwarding (creating abstractions that rewrite function calls entirely at compile-time). |
@zah it works with varagsLen I introduced some time ago template myTemplate(T: type, args: varargs[untyped]) =
var obj: T
when varargsLen(args) == 0:
obj.procWithDefaults()
else:
obj.procWithDefaults(args) |
I've switched to an in-house version of The main difference with the stdlib version is that it allows you to mix the varargs with additional arguments inserted in the call. |
The following valid code fails to compile at the moment:
The problem is that the empty forwarded varargs are not recognized as a valid way to call the proc
procWithDefaults
even though all the required non-default parameters have been supplied.The problem can be worked-around using the following trick:
Another work-around that should probably work, but currently doesn't is the following:
The text was updated successfully, but these errors were encountered: