www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1168] New: Passing a .stringof of an expression as a template value parameter results in the string of the type

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

           Summary: Passing a .stringof of an expression as a template value
                    parameter results in the string of the type
           Product: D
           Version: 1.012
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: deewiant gmail.com


(Set version as 1.012, since 1.013 wasn't in the list yet.)

template T(char[] s) {
        const char[] T = s;
}

char[] f(char[] s) {
        return s;
}

void main() {
        int foo;
        assert (foo.stringof == f(foo.stringof));  // works
        assert (foo.stringof == T!(foo.stringof)); // fails
}

T!(foo.stringof) results in "int", it should be "foo".


-- 
Apr 20 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1168


deewiant gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |reiner.pope gmail.com





*** Bug 1465 has been marked as a duplicate of this bug. ***


-- 
Sep 01 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1168


Jeremie Pelletier <jeremiep gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jeremiep gmail.com



PDT ---
The following patch to mtype.c fix the issue:

--- ..\src\orig\mtype.cpp    Thu Sep 03 01:01:40 2009
+++ ..\src\dmd\mtype.cpp    Sat Sep 05 16:42:50 2009
   -4530,6 +4530,11   
             goto Lerror;
             goto L3;
         }
+        else if(v && id == Id::stringof) {
+            e = new DsymbolExp(loc, s, 0);
+            *pe = new DotIdExp(loc, e, id);
+            return;
+        }
         t = s->getType();
         if (!t && s->isDeclaration())
             t = s->isDeclaration()->type;

It turns out stringof was applied on the type of the Dsymbol, not the symbol
itself.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 05 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1168


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                 CC|                            |clugdbug yahoo.com.au



Cool! Add 'patch' to the list of keywords when you've submitted a patch, it
makes them easier to track.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 07 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1168


Walter Bright <bugzilla digitalmars.com> changed:

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



02:12:29 PDT ---
Fixed dmd 1.048 and 2.033

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