Bug 13430 – Improve error message with wrong arg type to inout function
Status
RESOLVED
Resolution
WORKSFORME
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-09-06T08:42:51Z
Last change time
2021-03-29T06:24:25Z
Keywords
diagnostic
Assigned to
No Owner
Creator
Manu
Comments
Comment #0 by turkeyman — 2014-09-06T08:42:51Z
This error message had me scratching my head for half an hour. Please fix this situation to report the appropriate error.
This code produces the error:
Error: inout method db.ui.listadapter.S.f is not callable using a mutable object
struct S
{
inout(int) f(int x) inout // inout method
{
return x;
}
}
void f(size_t s)
{
S x;
// call it with the wrong type (size_t, expects int)
x.f(s); // very surprising error message
// call with appropriate type, no problem
x.f(cast(int)s);
}
Comment #1 by iamthewilsonator — 2021-03-29T06:24:25Z
This seems to have been fixed somewhere along the way. It now prints
onlineapp.d(14): Error: function `onlineapp.S.f(int x) inout` is not callable using argument types `(ulong)`
onlineapp.d(14): cannot pass argument `s` of type `ulong` to parameter `int x`