[Issue 20670] immutable template specialization pattern matches immutable struct, strips immutable
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu May 12 16:27:37 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=20670
--- Comment #7 from Paul Backus <snarwin+bugzilla at gmail.com> ---
D's type system currently guarantees that for all qualified types Q(T), there
exists the corresponding unqualified type T. Introducing special-case
exceptions to this guarantee is likely to break at least as much code as it
fixes (try `git grep 'Unqual!'` in Phobos to get a rough idea).
IMO if one wants to hint to users that a type should be used with a particular
qualifier by default, a better way (that does not require weird corner cases in
the type system) is to use a public alias to a qualified version of a private
type.
--- lib.d
module lib;
private struct StructImpl { }
alias Struct = immutable(StructImpl);
--- app.d
import lib;
Struct s;
static assert(is(typeof(s) == immutable));
---
--
More information about the Digitalmars-d-bugs
mailing list