Bug 10648 – std.traits.isMutable is true for struct defined immutable
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2013-07-15T10:13:00Z
Last change time
2013-07-15T18:07:35Z
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2013-07-15T10:13:33Z
With dmd 2.064alpha this code runs with no assert errors:
import std.traits: isMutable;
immutable struct Foo {}
void main () {
static assert(isMutable!Foo);
}
Issue found by JS:
http://forum.dlang.org/thread/[email protected]
Comment #1 by k.hara.pg — 2013-07-15T18:07:35Z
(In reply to comment #0)
> With dmd 2.064alpha this code runs with no assert errors:
>
>
> import std.traits: isMutable;
> immutable struct Foo {}
> void main () {
> static assert(isMutable!Foo);
> }
>
>
>
> Issue found by JS:
> http://forum.dlang.org/thread/[email protected]
It is not an issue. Because:
1. Qualified struct declaration and its behavior is properly documented.
http://dlang.org/struct#ConstStruct
2. The struct name `Foo` always represent 'mutable type Foo'. And, isMutable tests whether the type qualifier is mutable or not.