Thread overview
DMD fail when using both reflection and UDA
Jun 01, 2014
bioinfornatics
Jun 01, 2014
bioinfornatics
Jun 01, 2014
bioinfornatics
Jun 01, 2014
Philippe Sigaud
Jun 01, 2014
bioinfornatics
June 01, 2014
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;
}
June 01, 2014
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
June 01, 2014
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
June 01, 2014
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?
June 01, 2014
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