[Issue 4041] New: Error with ref or auto ref return from opOpAssign
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Apr 1 18:26:27 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4041
Summary: Error with ref or auto ref return from opOpAssign
Product: D
Version: 2.041
Platform: x86
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: aldacron at gmail.com
--- Comment #0 from Mike Parker <aldacron at gmail.com> 2010-04-01 18:26:25 PDT ---
##############################
struct Foo
{
int x;
ref Foo opOpAssign(string op)(ref Foo f) if(op == "+=")
{
x += f.x;
return this;
}
}
void main()
{
Foo f1 = Foo(1);
Foo f2 = Foo(2);
f2 += f1;
}
#################################
Results in:
refret.d(5): Error: variable refret.Foo.op only parameters or foreach
declaratio
ns can be ref
Change the return type from 'ref Foo' to 'auto ref Foo' and the same error
occurs. Remove the ref from the return and it compiles. Comment out the 'f2 +=
f1' and it compiles.
This happens on both 2.041 and 2.042. I haven't tried earlier versions.
BTW, 2.042 is missing from the version list here on Bugzilla.
--
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