www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14093] New: __traits(compiles, cast(Object)(tuple)) is true

https://issues.dlang.org/show_bug.cgi?id=14093

          Issue ID: 14093
           Summary: __traits(compiles, cast(Object)(tuple)) is true even
                    if it doesn't compile.
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: kpierre+dlang outlook.com

This code does not compile on most DMD compiler version on Linux:

    import std.typecons;

    void main()
    {
         Tuple!(int, "x", int, "y") point;
         static if (__traits(compiles, {auto newPoint = cast(Object)(point);}))
         {
             {auto newPoint = cast(Object)(point);}
         }
    }

The compiles trait evaluates to true, even though it's impossible to cast a
tuple to object.
The code compiles if I run it in DPaste version "DMD 2.x Git (cfb5842b49)". It
doesn't work in 2.065.0 or commit 7c769ec517e8acc086d92c9dc0d6a680b83f69f0.
Since this bug seems to come and go there should probably be a unit test for
it.

--
Jan 31 2015