[Issue 4843] New: Inconsistency in overloading ref vs. non-ref
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Sep 9 06:03:59 PDT 2010
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: nobody at puremagic.com
ReportedBy: dsimcha at yahoo.com
--- Comment #0 from David Simcha <dsimcha at 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: -------
More information about the Digitalmars-d-bugs
mailing list