On Tuesday, 14 November 2023 at 13:58:17 UTC, Paul Backus wrote:
It's easier to see if you compare the actual and expected argument lists side-by-side
Expected: (ref const(S1) s) const
Actual: ( const(S1) )
Mismatched 'this' argument
This would be a much better output. Is this something you made up or did you get it from one of the compilers? LDC2, which is what I tested with, reported in the format that I mentioned.
It might be something to add to the compiler that mismatches in
this qualifiers should be reported separately, especially since the mutable form has no explicit qualifier. But I guess this is only an issue for constructors, because normal const functions can be called with mutable objects.
That being said, I still consider this a bug, if the inout version works, the const version should work as well. I don't see the difference.
So an interesting thing, if I change the
int i to
int *i in
S2, instead of compiling I get the error:
Error: `inout` constructor `testinoutctor.S2.this` creates const object, not mutable
Which gives a much nicer error message!