Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2421 from 9rnsr/fix10726
[REG2.064a] Issue 10726 - Bogus Circular Reference error if opEquals defined and has a loop
- Loading branch information
Showing
8 changed files
with
205 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// PERMUTE_ARGS: | ||
|
||
public struct CirBuff(T) | ||
{ | ||
private T[] data; | ||
private size_t head = 0; | ||
private size_t size = 0; | ||
public size_t length() const { return size; } | ||
|
||
public bool opEquals(CirBuff!T d) @trusted | ||
{ | ||
if (length != d.length) | ||
return false; | ||
for (size_t i=0; i!=size; ++i) | ||
{ | ||
if (this.data[(this.head+i) % this.data.length] != | ||
d.data[(d.head + i) % d.data.length]) | ||
{ | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
} | ||
|
||
class Once | ||
{ | ||
Foo!Bar _bar; | ||
} | ||
|
||
class Bar | ||
{ | ||
static Once _once; | ||
mixin(sync!(Once, "_once")); | ||
} | ||
|
||
class Foo(T = int) | ||
{ | ||
CirBuff!T _buff; | ||
} | ||
|
||
template sync(T, string U = "this", size_t ITER = 0) | ||
{ | ||
static if (ITER == __traits(derivedMembers, T).length) | ||
enum sync = ""; | ||
else | ||
{ | ||
enum string mem = __traits(derivedMembers, T)[ITER]; | ||
enum string sync = | ||
"static if(! __traits(isVirtualMethod, " ~ U ~ "." ~ mem ~ ")) { }" | ||
~ sync!(T, U, ITER+1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
import test10567a; | ||
|
||
template TypeTuple(TL...) { alias TL TypeTuple; } | ||
|
||
void main() | ||
{ | ||
auto i = BigInt([100]); | ||
auto j = BigInt([100]); | ||
foreach (BigInt; TypeTuple!(BigInt1, BigInt2, BigInt3)) | ||
{ | ||
auto i = BigInt([100]); | ||
auto j = BigInt([100]); | ||
|
||
assert(typeid(BigInt).compare(&i, &j) == 0); | ||
assert(typeid(BigInt).equals(&i, &j) == true); | ||
assert(typeid(BigInt).compare(&i, &j) == 0); | ||
} | ||
} |
Oops, something went wrong.