www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21008] New: dmd segfaults because of __traits(getMember, ...)

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

          Issue ID: 21008
           Summary: dmd segfaults because of __traits(getMember, ...) and
                    virtual function overriding
           Product: D
           Version: D2
          Hardware: x86
                OS: All
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bitworld qq.com

When compiling the test code with dmd, the compiler will crash.

Test with dmd 2.092.0 and 2.088.1 on Windows and Linux.


Here is the code:
======================================
void main() {}

import std.traits;

abstract class Controller {
    bool after();
}

abstract class ControllerBase(T) : Controller {
    override bool after() {
        return true;
    }

    mixin(handleMiddlewareAnnotation!(T));
}

class DemoController : ControllerBase!DemoController {

    // Bug mark A
    override bool after() {
        return true;
    }
}

string handleMiddlewareAnnotation(T)() {

    foreach (memberName; __traits(allMembers, T)) {
        alias currentMember = __traits(getMember, T, memberName); // Bug mark B
    }

    return "";
}
======================================

After commenting out the mark A or the mark B, the compiling will pass.

--
Jul 03 2020