Bug 17186 – Type inference for parameters with default argument
Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-02-15T19:22:08Z
Last change time
2023-05-18T10:51:17Z
Keywords
preapproved
Assigned to
No Owner
Creator
Jacob Carlborg
Comments
Comment #0 by doob — 2017-02-15T19:22:08Z
D supports type inference in my places, like variable declarations:
auto a = 3;
But the same thing doesn't work with parameters, neither template or regular parameters:
void foo(auto a = 3);
void foo(auto a = 3)();
Implementing this feature would allow for some function signatures to be shorter and make the language more consistent. Currently it seems like an arbitrary limitation.
Comment #1 by uplink.coder — 2017-02-15T19:28:49Z
a function signature is just that.
The signature of the function, allowing auto in the signature makes it uninformative
Comment #2 by doob — 2017-02-15T19:30:22Z
It's already allowed for the return type.
Comment #3 by uplink.coder — 2017-02-15T19:33:21Z
(In reply to Jacob Carlborg from comment #2)
> It's already allowed for the return type.
Which already wrecks havoc when trying to generate headers.