AssociativeArray!(string,double) vs. double[string]

Martin Nowak dawg at dawgfoto.de
Fri Jul 29 14:07:31 PDT 2011


This is a compiler bug. To allow usage of AA functions from druntime,  
properties of built-in associative arrays are forwarded to the template  
instance AssociativeArray!(K, V). This is erroneously also done for .init  
and .stringof.
There are some bug reports for this.
http://d.puremagic.com/issues/show_bug.cgi?id=5683

If it were only init/stringof/mangleof this can be easily fixed.

On Thu, 28 Jul 2011 23:55:45 +0200, Jens Mueller <jens.k.mueller at gmx.de>  
wrote:

> Hi,
>
> I'm trying to compare the type of associative arrays:
>
> unittest {
>     import std.stdio;
>
>     double[string] aa;
>
>     writeln(typeof(aa).stringof);
>     writeln(typeof(aa.init).stringof);
>
>     writeln(typeid(aa));
>     writeln(typeid(aa.init));
>
>     assert(is(typeof(aa) == typeof(aa.init)));
> }
>
> The assert fails which puzzles me. Why is the type of the expression aa
> not the same as the type of the expression aa.init? There is a struct
> AssociativeArray!(key, value) involved (part of druntime). The typeid
> (i.e. the TypeInfo of the respective types of the expressions) are not
> the same (double[immutable(char)[]] vs.
> object.AssociativeArray!(string,double).AssociativeArray).
>
> Jens




More information about the Digitalmars-d mailing list