[Issue 8657] TypeInfo generated for const/immutable static arrays not transitive

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Sep 16 10:23:02 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8657



--- Comment #2 from Rainer Schuetze <r.sagitario at gmx.de> 2012-09-16 10:23:53 PDT ---
(In reply to comment #1)
> (In reply to comment #0)
> [snip]
> TypeInfo_Const.next specifies the TypeInfo object of the type that removed head
> const qualifier from original type.

Please note the difference between base and next (as used in object_.d, see
also issue 8656 for naming confusion). What you describe is
"TypeInfo_Const.base", though called "next" in object.di. As can be seen from
the other types, TypeInfo.next does the indirection and yields the type of the
element pointed to or in the array.

> And, Removing const from const(int[2]) is int[2], not const(int)[2].
> It's just same as std.traits.Unqual.
> 
>   pragma(msg, Unqual!(const(int[2])));  // prints const(int)[]
>   pragma(msg, Unqual!(const(int[2])));  // prints int[2]

I fail to spot the difference between the two statement ;-) I guess you meant
to remove the 2 in the first line.

> 
> Additionally, const(int)[2] is same as const(int[2]). There is just a
> syntactically difference.

That could also support my point of view: I'd very much expect
(cast(TypeInfo)typeid(const(int)[2])).next to be typeid(const(int)). Maybe the
runtime type information of a static array should be typed that way to start
with.

Even if I cannot convince you: What do you think about the transitivity of the
shared modifier in the example. Is it wrong then?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list