www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18866] New: Overload from opDispatch ignored in WithStatement


          Issue ID: 18866
           Summary: Overload from opDispatch ignored in WithStatement
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: simen.kjaras gmail.com

When opDispatch would introduce an overload to an existing function, and is
being invoked in a WithStatement, the global function is used in its stead:

string fun1() { return "global"; }
string fun2() { return "global"; }
struct S {
    string opDispatch(string name)() {
        return "struct";
    string fun2() {
        return "struct";

unittest {
    import std.stdio;
    with (S()) {
        // opDispatch overloading global:
        writeln("fun1: ", fun1()); // Prints 'global'
        // Member function overloading global:
        writeln("fun2: ", fun2()); // Prints 'struct'
        // opDispatch, no overloading:
        writeln("fun3: ", fun3()); // Prints 'struct'

Expected behavior here is that all three function calls print 'struct'.

May 16 2018