www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23279] New: Segmentation fault on mixin template + using


          Issue ID: 23279
           Summary: Segmentation fault on mixin template + using unknown
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: msnmancini hotmail.com

This is an example code of what is causing a segmentation fault:

template getParams (alias fn) 
        static if ( is(typeof(fn) params == __parameters) )
        alias getParams = params;
template hasMethod(T, string method, Params...)
    enum hasMethod = __traits(hasMember, T, method) &&
is(getParams!(__traits(getMember, T, method)) == Params);

mixin template TestMx()
    static if(hasMethod!( typeof(this), "setIt", Tester)){}

class Tester
    mixin TestMx;
    void setIt(Sth sth){}

I don't know (or didn't test) on how to further reduce that, but it seems small

The error occurs when the mixin TestMx is called.

Jul 31 2022