[Issue 9354] New: overload resolution picks alias this over const conversion

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jan 19 02:55:34 PST 2013


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

           Summary: overload resolution picks alias this over const
                    conversion
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: nilsbossung at googlemail.com


--- Comment #0 from Nils <nilsbossung at googlemail.com> 2013-01-19 02:55:31 PST ---
test.d:
---
struct S {
    int i;
    alias i this;
}
void f(const S) {
}
void f(int) {
    assert(false); // line 8
}
void main() {
    f(S());
}
---

`rdmd test.d`:
---
core.exception.AssertError at test(8): Assertion failure
---

f(const S) should be called, not f(int). Conversion to const makes a better
match than  the implicit conversion of alias this:
http://dlang.org/function.html#function-overloading

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list