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: [email protected]
ReportedBy: [email protected]
--- Comment #0 from Andrej Mitrovic <[email protected]> 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: -------