January 12, 2024 [Issue 24334] New: parameter name is ignored in invocation of struct constructor with default values | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24334 Issue ID: 24334 Summary: parameter name is ignored in invocation of struct constructor with default values Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: jim@balter.name struct Foo { this(int a, int b = 2, int c = 3) { imported!"std.stdio".writefln!"a=%s b=%s c=%s"(a, b, c); } } void main() { auto foo = Foo(1, c: 99); } Expected output: a=1 b=2 c=99 Actual output: a=1 b=99 c=3 (This bug is dangerous, and quite shocking for a mature language.) Note that the problem is only with a constructor. e.g, this works correctly: struct Bar { static void bar(int a, int b = 2, int c = 3) { imported!"std.stdio".writefln!"a=%s b=%s c=%s"(a, b, c); } } void main() { Bar.bar(1, c: 99); } output: a=1 b=2 c=99 -- |
Copyright © 1999-2021 by the D Language Foundation