[Issue 18866] New: Overload from opDispatch ignored in WithStatement
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed May 16 14:29:16 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18866
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 at puremagic.com
Reporter: simen.kjaras at 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'.
--
More information about the Digitalmars-d-bugs
mailing list