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.
Comment #4 by nick — 2017-11-06T12:32:35Z
There was a pull for this before: https://github.com/dlang/dmd/pull/2270 https://issues.dlang.org/show_bug.cgi?id=10491 Now this is preapproved, it could be updated.
Comment #5 by hsteoh — 2018-01-28T07:36:26Z
Comment #6 by razvan.nitu1305 — 2023-05-18T10:51:17Z
*** This issue has been marked as a duplicate of issue 10491 ***