September 20, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11078

           Summary: Diagnostic for wrong RHS in property assign of a
                    property group should improve
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: andrej.mitrovich@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-09-20 13:56:05 PDT ---
-----
struct S1
{
    @property int value() { return 1; }
    @property void value(int n) { }
}

void main()
{
    S1 s1;
    s1.value = 1.0;
}
-----

$ dmd test.d
> test.d(12): Error: s1.value is not an lvalue

It seems the compiler first attempts to call "s1.value(1.0)" (the setter), but
gags the error, and then tries to call "s1.value() = 1.0" and emits a
diagnostic for the getter.

A more appropriate thing to do is to prefer writing a diagnostic for the setter. It is arguably more common to mistake the proper RHS type of an expression, and ref-return getter properties are quite rare.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 20, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11078



--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-09-20 13:57:14 PDT ---
(In reply to comment #0)
> $ dmd test.d
> > test.d(12): Error: s1.value is not an lvalue

To see the expected diagnostic, just comment out the getter and you'll get:

> test.d(12): Error: function test.S1.value (int n) is not callable using argument types (double)

Much better.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------