www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - DMD fail when using both reflection and UDA

reply "bioinfornatics" <bioifornatics fedoraproject.org> writes:
DMD (dmdfe 2.066) fail when i use UDA which store a delegate


code below works if i remove  section UDA otheswise it give this
error:

dmd: statement.c:714: ErrorStatement::ErrorStatement(): Assertion
`global.gaggedErrors || global.errors' failed.


is a bug  ?



------- CODE also on dpaste http://dpaste.dzfl.pl/3a3d660bd3bc
--------
import std.stdio;
import std.typecons : Tuple;
import std.typetuple : Filter;


struct attribute{}

 attribute
struct section( alias start, alias end)
{
      alias checkStart = start;
      alias checkEnd = end;
}

template hasSection(T)
{
      static bool helper()
      {
          foreach(memberName; __traits(allMembers, T))
          {
              foreach(attr; __traits(getAttributes,
__traits(getMember, T, memberName)))
              {
                  static if(is(attr == Section))
                      return true;
              }
          }
          return false;
      }

      enum hasSection = helper();
}

struct Data{
       section!( ( words ) =>  words[0] == ' '                 , (
words ) =>  words[0] == '\n' )
      string a;
       section!( ( words ) =>  words[0] > 63 && words[0] <115  , (
words ) =>  words[0] == '\n' )
      string b;
       section!( ( words ) =>  words[0] == '+'                 , (
words ) =>  words[0] == '\n' )
      string c;
}

template toTuple(T){
      static string maker(){
          string statement = "alias toTuple = Tuple!(";
          foreach(const memberName; __traits(allMembers, T)){
              //~ mixin(`alias f = Filter!(hasSection,
__traits(getAttributes, T.` ~ memberName ~ `));`);
              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;
}
Jun 01 2014
parent reply "bioinfornatics" <bioifornatics fedoraproject.org> writes:
On Sunday, 1 June 2014 at 16:02:47 UTC, bioinfornatics wrote:
 DMD (dmdfe 2.066) fail when i use UDA which store a delegate


 code below works if i remove  section UDA otheswise it give this
 error:

 dmd: statement.c:714: ErrorStatement::ErrorStatement(): 
 Assertion
 `global.gaggedErrors || global.errors' failed.


 is a bug  ?



 ------- CODE also on dpaste http://dpaste.dzfl.pl/3a3d660bd3bc
 --------
 import std.stdio;
 import std.typecons : Tuple;
 import std.typetuple : Filter;


 struct attribute{}

  attribute
 struct section( alias start, alias end)
 {
      alias checkStart = start;
      alias checkEnd = end;
 }

 template hasSection(T)
 {
      static bool helper()
      {
          foreach(memberName; __traits(allMembers, T))
          {
              foreach(attr; __traits(getAttributes,
 __traits(getMember, T, memberName)))
              {
                  static if(is(attr == Section))
                      return true;
              }
          }
          return false;
      }

      enum hasSection = helper();
 }

 struct Data{
       section!( ( words ) =>  words[0] == ' '                 , 
 (
 words ) =>  words[0] == '\n' )
      string a;
       section!( ( words ) =>  words[0] > 63 && words[0] <115  , 
 (
 words ) =>  words[0] == '\n' )
      string b;
       section!( ( words ) =>  words[0] == '+'                 , 
 (
 words ) =>  words[0] == '\n' )
      string c;
 }

 template toTuple(T){
      static string maker(){
          string statement = "alias toTuple = Tuple!(";
          foreach(const memberName; __traits(allMembers, T)){
              //~ mixin(`alias f = Filter!(hasSection,
 __traits(getAttributes, T.` ~ memberName ~ `));`);
              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;
 }
ok it seem problem from my code a type string i need to understand why
Jun 01 2014
parent reply "bioinfornatics" <bioifornatics fedoraproject.org> writes:
stupid me bug was at the end

a[0] = 1;
   become
   a[0] = "1";

but error error was so stnange to me i though that was a bug
Jun 01 2014
parent reply Philippe Sigaud via Digitalmars-d-learn writes:
In any case, it's an internal compiler error, so it's a bug. Users
should never see ICEs.
Could you please report it, with the entire error message?
Jun 01 2014
parent "bioinfornatics" <bioifornatics fedoraproject.org> writes:
On Sunday, 1 June 2014 at 16:18:45 UTC, Philippe Sigaud via
Digitalmars-d-learn wrote:
 In any case, it's an internal compiler error, so it's a bug. 
 Users
 should never see ICEs.
 Could you please report it, with the entire error message?
Ok thanks is don at https://issues.dlang.org/show_bug.cgi?id=12838
Jun 01 2014