Bug 10418 – bad error message: "not a property"

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-19T16:31:00Z
Last change time
2013-06-19T21:01:08Z
Assigned to
nobody
Creator
destructionator

Comments

Comment #0 by destructionator — 2013-06-19T16:31:26Z
=== 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.
Comment #1 by destructionator — 2013-06-19T16:32:20Z
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).
Comment #2 by andrej.mitrovich — 2013-06-19T16:52:10Z
(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.
Comment #3 by k.hara.pg — 2013-06-19T20:58:46Z
(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
Comment #4 by k.hara.pg — 2013-06-19T21:01:08Z
*** Issue 10417 has been marked as a duplicate of this issue. ***