[Issue 5010] New: Error messages for properties could be improved

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 7 07:23:18 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=5010

           Summary: Error messages for properties could be improved
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: clugdbug at yahoo.com.au


--- Comment #0 from Don <clugdbug at yahoo.com.au> 2010-10-07 07:22:52 PDT ---
The problem with the error messages is that they refer to the property in the
syntax it has AFTER conversion to a function call.
----

CASE 1: Assignments cannot be chained through properties

@property
void prop(int x) {}

void main()
{
   int a = prop = 6;
}
----
bug.d(7): Error: expression prop(6) is void and has no value

----
The error message is quite difficult to understand. I do think it is quite
reasonable that it fails to compile, though, since the getter could be defined
as:

@property
int prop() { return 2; }

Secondly, the error messages when you use a getter (eg, int a = prop; ), when
only a setter is defined, are:

bug.d(7): Error: function test0.prop (int x) is not callable using argument
types ()
bug.d(8): Error: expected 1 function arguments, not 0
bug.d(9): Error: expression prop() is void and has no value

This error message is confusing because no parens were used.

The same situation applies when trying to use a setter, when only a getter is
defined.

-- 
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