Bug 11078 – Diagnostic for wrong RHS in property assign of a property group should improve
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-09-20T13:56:00Z
Last change time
2014-01-15T09:44:40Z
Keywords
diagnostic, pull
Assigned to
nobody
Creator
andrej.mitrovich
Comments
Comment #0 by andrej.mitrovich — 2013-09-20T13:56:05Z
-----
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.
Comment #1 by andrej.mitrovich — 2013-09-20T13:57:14Z
(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.
Comment #2 by dlang-bugzilla — 2013-12-17T08:56:30Z
This is a regression in 2.058. DMD 2.057 produces the expected error message.