www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10726] New: Bogus Circular Reference error if opEquals defined and has a loop

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10726

           Summary: Bogus Circular Reference error if opEquals defined and
                    has a loop
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: puneet coverify.org



---
$ git show
commit 4db28ef01443e3e649fe79824889c0ec620f6e72
Merge: a218f47 b2d2bd9
Author: Walter Bright <walter walterbright.com>
Date:   Mon Jul 29 00:33:34 2013 -0700



    [DDMD] Do not pass strings to C varargs functions


Here is the reduced test case. I am getting the following error:

$ dmd test.d
test.d(19): Error: circular reference to 'test.Once._bar'
test.d(22): Error: template instance test.CirBuff!(Bar) error instantiating
test.d(15):        instantiated from here: Foo!(Bar)
test.d(15): Error: template instance test.Foo!(Bar) error instantiating

Error disappears if I comment out for loop (lines 08-10) inside the opEquals
method. Also disappears if I change the name of the opEquals method to say
foobar. Also disappears if I do not use the isVirtualMethod trait on line 29.

// test.d
public struct CirBuff(T) {                                                // 01
  private T[] data;                                                       // 02
  private size_t head = 0;                                                // 03
  private size_t size = 0;                                                // 04
  public size_t length() const {return size;}                             // 05
  public bool opEquals(CirBuff!T d)  trusted {                            // 06
    if(length != d.length) return false;                                  // 07
    for(size_t i=0; i!=size; ++i)                                         // 08
      if(this.data[(this.head+i)%this.data.length] !=                     // 09
     d.data[(d.head+i)%d.data.length]) return false;                  // 10
    return true;                                                          // 11
  }                                                                       // 12
}                                                                         // 13
class Once {                                                              // 14
  Foo!Bar _bar;                                                           // 15
}                                                                         // 16
class Bar {                                                               // 17
  static Once _once;                                                      // 18
  mixin(sync!(Once, "_once"));                                            // 19
}                                                                         // 20
class Foo (T=int) {                                                       // 21
  CirBuff!T _buff;                                                        // 22
}                                                                         // 23
template sync(T, string U="this", size_t ITER=0) {                        // 24
  static if(ITER == __traits(derivedMembers, T).length) enum sync = "";   // 25
  else {                                                                  // 26
    enum string mem = __traits(derivedMembers, T)[ITER];                  // 27
    enum string sync =                                                    // 28
      "static if(! __traits(isVirtualMethod, " ~ U ~ "." ~ mem ~ ")) { }" // 29
      ~ sync!(T, U, ITER+1);                                              // 30
  }                                                                       // 31
}                                                                         // 32

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 29 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10726


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid



https://github.com/D-Programming-Language/dmd/pull/2421

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 06 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10726




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/805dd761dd85c98d60b3957bd5679cdbbf23c7f2
fix Issue 10726 - Bogus Circular Reference error if opEquals defined and has a
loop

This is also the better fix for issue 10567.

https://github.com/D-Programming-Language/dmd/commit/4e9a7b169ef9a570a0fbf3244733eced542c16c2


[REG2.064a] Issue 10726 - Bogus Circular Reference error if opEquals defined
and has a loop

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 11 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10726


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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