www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12838] New: Dmd show ICEs when using Tuple and wrong type

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

          Issue ID: 12838
           Summary: Dmd show ICEs when using Tuple and wrong type
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: bioinfornatics gmail.com

------------ CODE
import std.typecons     : Tuple;

struct Data
{
    string a;
}


template toTuple(T){
     static string maker(){
         string statement = "alias toTuple = Tuple!(";
         foreach(const memberName; __traits(allMembers, T))
            statement ~=  typeof(__traits(getMember, T, memberName)).stringof 
~ ",\"" ~ memberName ~ "\", " ;
         statement = statement[0..$-2] ~ ") ;" ; // $-2 to remove extra comma
         return statement;
     }
     mixin( maker() );
}


void main()
{
     alias A = toTuple!Data;    A a;
     a[0] = 1;
     a.x = 1;
}

------------

$ LD_LIBRARY_PATH=/opt/dmd/lib/ /opt/dmd/bin/dmd testBug.d 
dmd: statement.c:714: ErrorStatement::ErrorStatement(): Assertion
`global.gaggedErrors || global.errors' failed.
Abandon (core dumped)

------------

a[0] expect a string but here intentionnaly i provide a int to show a dmd bug

--
Jun 01 2014