Bug 6091 – [d-p-l.org] Description for "Modifier casting" is misleading

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-06-02T12:36:00Z
Last change time
2012-01-20T22:21:55Z
Assigned to
nobody
Creator
schveiguy

Comments

Comment #0 by schveiguy — 2011-06-02T12:36:08Z
From this page: http://d-programming-language.org/expression.html ------ Casting to a CastQual adds the qualifier to the type of the UnaryExpression. Casting to the empty ( ) has the effect of removing any top level const or immutable type modifiers from the type of the UnaryExpression. ------ When I read this, I interpret casting to a CastQual as only *adding* the given modifiers, but it actually *replaces* the modifiers. For example: shared int x; assert(is(typeof(cast(const)x) == const int)); Note, shared is *removed* from the modifiers. For the second statement, casting with ( ) removes shared as well: shared int x; assert(is(typeof(cast()x) == int)); Finally, "Casting to the empty ( )" reads poorly. I would say "Cast with no Type or CastQual inside the parentheses has the effect of removing any top level const, immutable, or shared type modifiers from the type of the UnaryExpression." I also would like to see examples here, feel free to use my two above.
Comment #1 by github-bugzilla — 2012-01-20T22:21:14Z