Thread overview
[Issue 10418] New: bad error message: "not a property"
Jun 19, 2013
Adam D. Ruppe
Jun 19, 2013
Adam D. Ruppe
Jun 19, 2013
Andrej Mitrovic
Jun 20, 2013
Kenji Hara
Jun 20, 2013
Kenji Hara
June 19, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10418

           Summary: bad error message: "not a property"
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: destructionator@gmail.com


--- Comment #0 from Adam D. Ruppe <destructionator@gmail.com> 2013-06-19 16:31:26 PDT ---
===
struct S {
        @property void number(int a) { }
}

void main() {
        S s;
        s.number = "10";
}
===

$ dmd test22
test22.d(7): Error: not a property s.number


As you can see, it obviously is a property, but it takes int and I gave it a string.

A better message would be

Error: not a property s.number(int)

or better yet,

Error: cannot implicitly convert expression ("10") of type string to int

especially since there are no overloads. If there were, I think what would be best is something like:

Error: no matching function "number" for arguments (string). Did you mean
number(int)?



Listing all possible overloads could lead to really spammy messages, but if it ran the spell check algorithm on the type signatures and gave the closest match(s), I think that would be manageable and generally useful, in all cases with overloaded functions.

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



--- Comment #1 from Adam D. Ruppe <destructionator@gmail.com> 2013-06-19 16:32:20 PDT ---
oops, I meant for the first better one:

Not a property: number(string)

since that's what it is trying to do, not number(int).

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


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich@gmail.com


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-06-19 16:52:10 PDT ---
(In reply to comment #0)
> ===
> struct S {
>         @property void number(int a) { }
> }
> 
> void main() {
>         S s;
>         s.number = "10";
> }
> ===
> 
> $ dmd test22
> test22.d(7): Error: not a property s.number

Hmm in git-head it's:

test.d(12): Error: function test.S.number (int a) is not callable using
argument types (string)

Looks like it's fixed.

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


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2013-06-19 20:58:46 PDT ---
(In reply to comment #2)
> (In reply to comment #0)
> > test22.d(7): Error: not a property s.number
> 
> Hmm in git-head it's:
> 
> test.d(12): Error: function test.S.number (int a) is not callable using
> argument types (string)
> 
> Looks like it's fixed.

When bug 10103 was fixed, it had been improved at the same time.

https://github.com/D-Programming-Language/dmd/pull/2047#discussion_r4298441

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



--- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> 2013-06-19 21:01:08 PDT ---
*** Issue 10417 has been marked as a duplicate of this issue. ***

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