[Issue 2355] is() doesn't resolve aliases before template matching

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Apr 8 06:00:30 PDT 2009


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


clugdbug at yahoo.com.au changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|is() fails to recognize a   |is() doesn't resolve aliases
                   |static array                |before template matching




------- Comment #1 from clugdbug at yahoo.com.au  2009-04-08 08:00 -------
Actually, the bug is not really a problem with static arrays. The problem is
just that is() isn't resolving aliases. If you replace 'size_t' with 'int' or
'uint', it works fine.
BTW the original code no longer works, since literals are now dynamic arrays,
not static arrays.
--------
template IsStaticSmart(T) {
  static if (is( T E : E[S], int S))
    enum IsStaticSmart = "true: " ~ E.stringof;
  else
    enum IsStaticSmart = "false";
}

alias int AliasInt;

template IsStaticSmart2(T) {
  static if (is( T E : E[S], AliasInt S))
    enum IsStaticSmart2 = "true: " ~ E.stringof;
  else
    enum IsStaticSmart2 = "false";
}

char [3] z;

pragma(msg, IsStaticSmart!(typeof(z)));
pragma(msg, IsStaticSmart2!(typeof(z)));

DMD2.028 displays:
true: char
false


-- 



More information about the Digitalmars-d-bugs mailing list