On Tuesday, 31 July 2018 at 21:54:54 UTC, Steven Schveighoffer
wrote:
Because inout is trying to combine all mutability modifiers
into one. You want to specify the type, not the mutability, in
the template parameter T.
Ahhh. Ok I see... I think.
This doesn't make sense. Can you post runnable code?
Hehe, ok, so I fell victim to compiler generating an error for
number 3 and then nothing else :p But yes you're right, if I
comment out number 3 then 6 errors as well. Sorry my bad!
When I go back to your original failing example, and replace
the 3 with immutable(int)(3), it still fails.
So for 3, compiler sees the instantiation:
inout(W!(immutable int)) wrap(immutable(int))
If I understood you correctly?
Yes. You can see for yourself with pragma msg:
pragma(msg, typeof(t)); // immutable(int)
But then what does it see in number 6, which works fine?
I'm skeptical this is the case.
Note that you may only see the instantiation error ONCE.
Yep, you nailed that one.
And why is 2 ok if 3 is not?
because inout(const(T)) cannot have its inout removed.
Because it may be an immutable? Or?
But the complaint is really the issue. Clearly inout is
specified, so it shouldn't complain that it isn't.
Aye. I guess that's right.
-Steve