digitalmars.D.bugs - [Issue 4690] New: ref return should allow assignment if not overridden
- d-bugmail puremagic.com (50/50) Aug 20 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4690
- d-bugmail puremagic.com (11/11) Aug 12 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4690
http://d.puremagic.com/issues/show_bug.cgi?id=4690 Summary: ref return should allow assignment if not overridden Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Keywords: rejects-valid Severity: major Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: dsimcha yahoo.com struct Foo { uint num; property ref uint front() { return num; } ref uint opIndex(size_t index) { return num; } } void main() { Foo foo; foo.front++; // Works foo.front += 1; // error 1 foo.front = 1; // error 2 foo[0] = 1; // error 3 } If something returns by reference then it should be usable for assignment, though if the class/struct contains an explicit setter property or opIndexAssign, this should override assignment via ref return. Here are the error messages produced. test9.d(16): Error: 'foo.front' is not a scalar, it is a property ref uint() test9.d(16): Error: incompatible types for ((foo.front) += (1)): ' property ref uint()' and 'int' test9.d(17): Error: function test9.Foo.front () is not callable using argument types (int) test9.d(17): Error: expected 0 arguments, not 1 for non-variadic function type property ref uint() test9.d(18): Error: operator [] assignment overload with opIndex(i, value) illegal, use opIndexAssign(value, i) I'm aware that other bugs have reported bits and pieces of this problem, but I think this is a clearer bug report on the more general issue. Also, marking as major because it's a significant impedement to library development in std.range. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 20 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4690 David Simcha <dsimcha yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED Can't reproduce this anymore. Must have been fixed a long time ago. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 12 2011