Issue 17186 - Type inference for parameters with default argument
Summary: Type inference for parameters with default argument
Status: RESOLVED DUPLICATE of issue 10491
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords: preapproved
Depends on:
Blocks:
 
Reported: 2017-02-15 19:22 UTC by Jacob Carlborg
Modified: 2023-05-18 10:51 UTC (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Jacob Carlborg 2017-02-15 19:22:08 UTC
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 Stefan Koch 2017-02-15 19:28:49 UTC
a function signature is just that.
The signature of the function, allowing auto in the signature makes it uninformative
Comment 2 Jacob Carlborg 2017-02-15 19:30:22 UTC
It's already allowed for the return type.
Comment 3 Stefan Koch 2017-02-15 19:33:21 UTC
(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 Nick Treleaven 2017-11-06 12:32:35 UTC
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 6 RazvanN 2023-05-18 10:51:17 UTC

*** This issue has been marked as a duplicate of issue 10491 ***