www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9575] New: __traits(compiles, mixin()) incorrectly returns false

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

           Summary: __traits(compiles, mixin()) incorrectly returns false
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: callumenator gmail.com


--- Comment #0 from callumenator gmail.com 2013-02-22 13:44:47 PST ---
DMD 2.062

void main()
{
   enum test = "auto v = new int;";
   pragma(msg, __traits(compiles, mixin(test))); // 'false'
   mixin(test); // compiles
}

A workaround is to wrap the test code in braces:
enum test = "{auto v = new int;}"; // __traits(compiles) == true

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 22 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9575


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich gmail.com
         Resolution|                            |INVALID


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-02-22
14:04:03 PST ---
See the traits documentation:

http://dlang.org/traits.html#compiles

"The arguments cannot be statements or declarations."

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 22 2013