[Issue 14190] New: Overload sets example incorrect

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Feb 16 09:14:16 PST 2015


https://issues.dlang.org/show_bug.cgi?id=14190

          Issue ID: 14190
           Summary: Overload sets example incorrect
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: spec
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: thecybershadow at gmail.com

http://dlang.org/function.html#overload-sets specifies the following example:

/////////////////////////// A.d //////////////////////////
module A;
void foo() { }
void foo(long i) { }
/////////////////////////// B.d //////////////////////////
module B;
class C { }
void foo(C) { }
void foo(int i) { }
///////////////////////// test.d /////////////////////////
import A;
import B;

void bar(C c)
{
    foo();    // calls A.foo()
    foo(1L);  // calls A.foo(long)
    foo(c);   // calls B.foo(C)
    foo(1,2); // error, does not match any foo
    foo(1);   // error, matches A.foo(long) and B.foo(int)
    A.foo(1); // calls A.foo(long)
}
//////////////////////////////////////////////////////////

However, the line:

    foo(1L);  // calls A.foo(long)

doesn't actually work:

test.d(7): Error: B.foo at B.d(4) conflicts with A.foo at A.d(3)

--


More information about the Digitalmars-d-bugs mailing list