Comment #0 by erikas.aubade — 2015-06-05T00:31:22Z
DMD as of 2.067.1 will complain about missing a default value if you ask for a
typesafe variadic array after a parameter with a default value. (And it does not allow you to set a default value on the variadic.)
Given that any variadic function may be called with no arguments in the variadic section, it seems like this should be permitted after a default argument. (And indeed, variadic functions with no type specifications seem to work fine.)
example code:
//gives "Error: default argument expected for argv"
void func1 (size_t argc = 0, string[] argv...) {
}
import core.vararg;
//Does not issue an error.
void func2 (size_t argc = 0, ...) {
}
void main() {
}
Comment #1 by schveiguy — 2015-06-05T02:48:59Z
I found something that works, but the syntax is a little weird (BTW, this is not in the grammar, not sure if it's accidentally accepted):
void func1(size_t argc = 0, string[] argv = null...)
I don't know if this is intentional. I'm going to bring it up on the newsgroup.
Comment #2 by snarwin+bugzilla — 2024-02-08T05:23:20Z
*** Issue 24372 has been marked as a duplicate of this issue. ***
Comment #3 by snarwin+bugzilla — 2024-02-08T05:28:04Z
As described in issue 24372, this now causes an internal compiler error instead of printing an error message.
Minimal example:
---
void func(size_t argc = 0, string[] argv...) {}
void main()
{
func();
}
---
Comment #4 by razvan.nitu1305 — 2024-09-11T14:20:49Z
*** This issue has been marked as a duplicate of issue 24760 ***