Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[enh] fix issue 10491 - Type inference for function arguments with default value #2270

Closed
wants to merge 1 commit into from

Conversation

hpohl
Copy link
Contributor

@hpohl hpohl commented Jun 28, 2013

http://d.puremagic.com/issues/show_bug.cgi?id=10491

void foo(i = 10, immutable f = 10.0f, const d = 10.0)
{
    static assert(is(typeof(i) == int));
    static assert(is(typeof(f) == immutable float));
    static assert(is(typeof(d) == const double));
}

struct S(T) { T val; }

void bar(T)(x = S!T("str"))
{
    static assert(is(typeof(x) == S!T));
}

@9rnsr
Copy link
Contributor

9rnsr commented Jun 29, 2013

I have negative opinions against doing this. See my comment in bugzilla.
http://d.puremagic.com/issues/show_bug.cgi?id=10491#c2

@hpohl
Copy link
Contributor Author

hpohl commented Jul 8, 2013

I'd like to hear what @andralex or @WalterBright think about this before we close this down.

@andralex
Copy link
Member

andralex commented Jul 9, 2013

@hpohl it's a nice idea but on the wrong side of the cost/benefit analysis. Will close this now. Keep them coming though!

@andralex andralex closed this Jul 9, 2013
@ntrel
Copy link
Contributor

ntrel commented Nov 6, 2017

This feature is now pre-approved BTW (so we can use it for const e = Enum.member without verbosity):
https://issues.dlang.org/show_bug.cgi?id=17186

I don't think void foo10491(a = 10, b = null) should be allowed, a storage class should probably be required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants