[Issue 10583] New: DMD 2.063 dumps core with mixins involving __traits(getProtection, ..

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jul 9 10:21:04 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10583

           Summary: DMD 2.063 dumps core with mixins involving
                    __traits(getProtection, ..
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: puneet at coverify.org


--- Comment #0 from Puneet Goel <puneet at coverify.org> 2013-07-09 10:21:03 PDT ---
Here is the test code. On compiling I get:
dmd: traits.c:288: virtual Expression* TraitsExp::semantic(Scope*): Assertion
`protName' failed.
Aborted (core dumped)

Also note that if I uncomment line 37 and comment out line 36, dmd compiles the
code smoothly.

///////////// Test Code starts here
enum sync;                                                     // 1
                                                               // 2
public template get_sync(size_t I, A...) {                     // 3
  static if(I == A.length)                                     // 4
    enum bool get_sync = false;                                // 5
  else static if(is(A[I] == sync))                             // 6
         enum bool get_sync = true;                            // 7
    else                                                       // 8
      enum bool get_sync = get_sync!(I+1, A);                  // 9
}                                                              // 10
                                                               // 11
template add_sync(T, size_t ITER=0) {                          // 12
  static if(ITER == (__traits(derivedMembers, T).length)) {    // 13
    enum string add_sync = "";                                 // 14
  } else {                                                     // 15
    enum string mem = __traits(derivedMembers, T)[ITER];       // 16
    enum string add_sync =                                     // 17
      "mixin(add_sync!(get_sync!(0, __traits(getAttributes, "  // 18
      ~ mem ~ ")), __traits(getProtection, "                   // 19
      ~ mem ~ "), \"" ~ mem ~ "\")); " ~ add_sync!(T, ITER+1); // 20
  }                                                            // 21
}                                                              // 22
                                                               // 23
template add_sync(bool A, string P, string M) {                // 24
  static if(A) {                                               // 25
    enum string add_sync = " auto " ~ M[1..$] ~                // 26
      "() {synchronized(this) return " ~ M ~ ";}";             // 27
  } else {                                                     // 28
    enum string add_sync = "";                                 // 29
  }                                                            // 30
}                                                              // 31
                                                               // 32
class derived {                                                // 33
  mixin(add_sync!(derived));                                   // 34
  @sync private bool _bar;                                     // 35
  void frop() {}                                               // 36
  // private void frop() {}                                    // 37
}                                                              // 38

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list