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

Inconsistent overload resolution depending on member values of Rvalue struct objects #19222

Open
dlangBugzillaToGithub opened this issue Jan 1, 2017 · 1 comment
Labels

Comments

@dlangBugzillaToGithub
Copy link

Ali Cehreli (@acehreli) reported this on 2017-01-01T01:33:24Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=17050

Description

Because no member nor struct type is different below, all calls are expected to be resolved to the same foo overload. However, that's not the case:

struct S {
    const(int)[] c;
}

int foo(S s) {
    return 1;
}

int foo(immutable(S) s) {
    return 2;
}

void main() {

    // This call is resolved to foo(S):
    const(int)[] arr;
    assert(foo(const(S)(arr)) == 1);

    // These are unexpectedly resolved to foo(immutable(S)):
    assert(foo(const(S)()) == 1);        // FAILS
    assert(foo(const(S)(null)) == 1);    // FAILS
}

Ali
@dlangBugzillaToGithub
Copy link
Author

acehreli commented on 2017-01-01T01:35:42Z

Related forum thread:

  http://forum.dlang.org/post/o4447c$21lf$1@digitalmars.com

Ali

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

No branches or pull requests

1 participant