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

2022-12-17 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=8657

Iain Buclaw  changed:

   What|Removed |Added

   Priority|P2  |P3

--


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

2012-09-16 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8657



--- Comment #2 from Rainer Schuetze  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: ---


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

2012-09-16 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8657



--- Comment #1 from Kenji Hara  2012-09-16 04:47:16 PDT ---
(In reply to comment #0)
[snip]
> It shows that the next and base properties of the TypeInfo generated for
> const(int[2]) and immutable(int[2]) lose the qualifier. This does not happen
> for "shared".

I think this is expected behavior, because const(int[2]) is value type.

TypeInfo_Const.next specifies the TypeInfo object of the type that removed head
const qualifier from original type.
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]

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

  alias const(int)[2] T1;
  alias const(int[2]) T2;
  static assert(is(T1 == T2));  // they are same
  pragma(msg, T1);   // prints const(int[2])
  pragma(msg, T2);   // prints const(int[2])

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