immutable method not callable using argument types () - doesn't make sense

Timon Gehr timon.gehr at gmx.ch
Wed Feb 6 15:31:20 PST 2013


On 02/07/2013 12:13 AM, Lee Braiden wrote:
> On Tuesday, 9 October 2012 at 22:47:16 UTC, denizzzka wrote:
>> On Tuesday, 27 March 2012 at 12:57:18 UTC, bearophile wrote:
>>> Steven Schveighoffer:
>>>
>>>> So what the compiler is saying is that you can't call dup with
>>>> arguments (), you must call it with arguments '() immutable',
>>>> meaning you must call it on an immutable B, not a mutable B.
>>>
>>> Any space for compiler error message improvements here?
>>
>> +1, spent two hours with a similar problem
>
> +2.  I wasted a little time on this too.  Not much, but frustratingly
> more than necessary.
>
> Why someone would write that error message makes SOME sense when
> explained, but the error message itself is still non-sensical ;)

I am writing a D compiler front end, and currently the following message 
is displayed for the example:

A.d:22:9: error: receiver for member function 'dup' is unqualified, but 
'immutable' is required
     f = g.dup;
         ^~~~~

Is this what you'd want?


More information about the Digitalmars-d mailing list