Bug 10726 – Bogus Circular Reference error if opEquals defined and has a loop

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-07-29T05:01:00Z
Last change time
2013-08-12T11:11:02Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
puneet

Comments

Comment #0 by puneet — 2013-07-29T05:01:25Z
$ git show commit 4db28ef01443e3e649fe79824889c0ec620f6e72 Merge: a218f47 b2d2bd9 Author: Walter Bright <[email protected]> Date: Mon Jul 29 00:33:34 2013 -0700 Merge pull request #2395 from yebblies/strvararg [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
Comment #1 by k.hara.pg — 2013-08-06T18:59:29Z
Comment #2 by github-bugzilla — 2013-08-11T23:46:50Z
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 Merge pull request #2421 from 9rnsr/fix10726 [REG2.064a] Issue 10726 - Bogus Circular Reference error if opEquals defined and has a loop