www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2861] New: Forward reference of .stringof in a template gives wrong value

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

           Summary: Forward reference of .stringof in a template gives wrong
                    value
           Product: D
           Version: 1.042
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: clugdbug yahoo.com.au


If you reverse the order of the declaration of x and Type, it works correctly.
For D2, change declaration of x to:  enum x = Type.stringof;
This is very similar to bug 934. With my patch applied, the equivalent
situation for .mangleof works correctly.
----
template Templ(T) {
   const char[] x = Type.stringof;
   alias T Type;
}

void main() {
    static assert(Templ!(int).x =="int");
}


-- 
Apr 20 2009
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2861


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




--- Comment #1 from Don <clugdbug yahoo.com.au>  2009-08-31 07:57:51 PDT ---
Fixed DMD2.030 and 1.045.
This works now.
Test case was wrong, though, should have been:
--
template Templ(T) {
   const char[] x = (Type).stringof;
   alias T Type;
}

void main() {
    static assert(Templ!(int).x =="int");
}

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