[Issue 20670] immutable template specialization pattern matches immutable struct, strips immutable

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat May 14 15:50:55 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=20670

--- Comment #9 from Dennis <dkorpel at live.nl> ---
(In reply to FeepingCreature from comment #8)
> I disagree with this claim, specifically because `immutable struct S`
> exists. I don't see where D makes the claim that this is the case.

D didn't make the claim, Paul made the claim. It follows from how immutable is
defined as something that modifies a type, see for example name mangling:

https://dlang.org/spec/abi.html#type_mangling

The compiler uses that for type identity. Also see how Type Qualifiers are
implemented as a field in the top level `Type` class:

https://github.com/dlang/dmd/blob/c4cea697e8658f103a69967587e75dd130506304/src/dmd/mtype.d#L334

> But `immutable struct` is not actually
> a qualifier, it's an "immutable declaration." This is currently, apparently,
> implemented as an implicit qualifier, which is what this bug is about

Do you want to invent a new `immutable struct` concept, with its own mangling?
Because I prefer not to complicate the type system, so I'm looking for a
solution without special cases.

> and at any rate is not what the spec says.

I can clarify the spec, but I don't think that's what you're after.

--


More information about the Digitalmars-d-bugs mailing list