D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 13430 - Improve error message with wrong arg type to inout function
Summary: Improve error message with wrong arg type to inout function
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 minor
Assignee: No Owner
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2014-09-06 08:42 UTC by Manu
Modified: 2021-03-29 06:24 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Manu 2014-09-06 08:42:51 UTC
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 Nicholas Wilson 2021-03-29 06:24:25 UTC
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`