digitalmars.D.bugs - [Issue 15859] New: opApply resolution on attributes
- via Digitalmars-d-bugs (66/66) Apr 01 2016 https://issues.dlang.org/show_bug.cgi?id=15859
https://issues.dlang.org/show_bug.cgi?id=15859 Issue ID: 15859 Summary: opApply resolution on attributes Product: D Version: D2 Hardware: x86_64 OS: Windows Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: qs.il.paperinik gmail.com Simple as that, shouldn't this work? The versions of opApply only differ in the attributes the delegate has. struct X { int opApply(int delegate(string) dg) { return dg("impure"); } int opApply(int delegate(string) pure dg) pure { return dg("pure"); } } void main() { X x; string result; x.opApply( (string s) { result = s; return 0; } ); writeln(result); // does compile and prints "pure". x.opApply( (string s) { result = s; write(""); return 0; } ); writeln(result); // does compile and prints "impure". /+ (1) foreach (string s; x) { result = s; } writeln(result); // does not compile: x.opApply matches more than one declaration +/ /+ (2) foreach (string s; x) { result = s; write(""); } writeln(result); // does not compile: x.opApply matches more than one declaration +/ } --
Apr 01 2016