http://d.puremagic.com/issues/show_bug.cgi?id=4843
Summary: Inconsistency in overloading ref vs. non-ref Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: dsim...@yahoo.com --- Comment #0 from David Simcha <dsim...@yahoo.com> 2010-09-09 06:03:33 PDT --- The following code compiles and correctly resolves the lvalue vs. non-lvalue overloading: import std.stdio; void doStuff(const ref int i) { writeln("Doing stuff by ref."); } void doStuff(const int i) { writeln("Forwarding to ref overload."); doStuff(i); } void main() { doStuff(1); } Similar code also works for classes and arrays. It seems to be broken for structs, though. The following code is rejected: import std.stdio; struct S {} bool fun(const ref S rhs) { return true; } bool fun(const S rhs) { return fun(rhs); } test9.d(12): Error: function test9.fun called with argument types: ((const(S))) matches both: test9.fun(ref const const(S) rhs) and: test9.fun(const const(S) rhs) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------