www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2355] New: is() fails to recognize a static array

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2355

           Summary: is() fails to recognize a static array
           Product: D
           Version: 2.019
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: snake.scaly gmail.com


template IsStatic(T : T[S], size_t S) {enum IsStatic = "true: " ~ T.stringof;}
template IsStatic(T) {enum IsStatic = "false";}

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

pragma(msg, IsStatic!(typeof("a")));
pragma(msg, IsStaticSmart!(typeof("a")));

Console output:

dmd -c test3.d
true: invariant(char) false --
Sep 11 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2355


clugdbug 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 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


-- 
Apr 08 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2355


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |code klickverbot.at


--- Comment #2 from yebblies <yebblies gmail.com> 2011-07-12 18:31:22 EST ---
*** Issue 5830 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 12 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2355


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|wrong-code                  |patch, rejects-valid
                 CC|                            |yebblies gmail.com
           Platform|x86                         |All
            Version|2.019                       |D2
         OS/Version|Windows                     |All


--- Comment #3 from yebblies <yebblies gmail.com> 2011-07-12 18:41:18 EST ---
https://github.com/D-Programming-Language/dmd/pull/238

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 12 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2355


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |puneet coverify.org


--- Comment #4 from yebblies <yebblies gmail.com> 2011-07-13 11:25:35 EST ---
*** Issue 6304 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 12 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2355


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


--- Comment #5 from Walter Bright <bugzilla digitalmars.com> 2011-07-17
17:21:46 PDT ---
https://github.com/D-Programming-Language/dmd/commit/caf0c7ff55d42002b534b4ef67f6581e1db078fe

https://github.com/D-Programming-Language/dmd/commit/145d6dbc3a542bac1451dec4fb77a1823e755777

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