[Issue 10726] New: Bogus Circular Reference error if opEquals defined and has a loop
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jul 29 05:01:28 PDT 2013
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 at puremagic.com
ReportedBy: puneet at coverify.org
--- Comment #0 from Puneet Goel <puneet at coverify.org> 2013-07-29 05:01:25 PDT ---
$ git show
commit 4db28ef01443e3e649fe79824889c0ec620f6e72
Merge: a218f47 b2d2bd9
Author: Walter Bright <walter at walterbright.com>
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
--
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