In Pure Factory Functions, it says what conversions are enabled for the result of a strongly pure function because the result is unique.
For one of my last PRs, I went through all possible combination of qualifiers and all pairs of these types. While I found no problematic conversion that was allowed, I did find conversions that should be allowed, but DMD rejects them. All of those involve inout
; in particular, whatever of mutable, const
, and immutable
you replace inout
on both sides with (if at both sides), the conversion is allowed for a pure factory function, but not for inout
. As far as I understand inout
, this makes no sense and they should be allowed by D’s type system.
Can someone take a look at the list and tell me if I’m mistaken with some (or all) of them?
“From” Type | “To” Type |
---|---|
unshared inout const |
shared inout const |
unshared inout |
shared inout |
unshared inout |
shared inout const |
unshared inout |
mutable unshared |
unshared inout |
mutable shared |
unshared const |
unshared inout const |
unshared const |
shared inout const |
shared inout const |
unshared inout const |
shared inout |
unshared inout |
shared inout |
unshared inout const |
shared inout |
mutable unshared |
shared inout |
mutable shared |
shared const |
unshared inout const |
shared const |
shared inout const |
mutable unshared | unshared inout |
mutable unshared | unshared inout const |
mutable unshared | shared inout |
mutable unshared | shared inout const |
mutable shared |
unshared inout |
mutable shared |
unshared inout const |
mutable shared |
shared inout |
mutable shared |
shared inout const |
Here is the code, for those interested.