www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9354] New: overload resolution picks alias this over const conversion

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 puremagic.com
        ReportedBy: nilsbossung googlemail.com


--- Comment #0 from Nils <nilsbossung 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 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: -------
Jan 19 2013