Array Wierdness

Ruby The Roobster rubytheroobster at yandex.com
Wed Aug 10 15:26:07 UTC 2022


On Wednesday, 10 August 2022 at 15:19:41 UTC, Ruby The Roobster 
wrote:
> Take the following code:
>
> ```d
> void main()
> {
>     shared class C { bool opEquals(const(shared(C)) rhs) const 
> shared  { return true;}}
>     const(C) c = new C();
>     const(C)[] a = [c];
>     const(C)[] b = [c];
>     assert(a[0] == b[0]);
> }
> ```
>
> This code (supposedly) checks whether ```a``` and ```b``` are 
> equal.  The thing is, it doesn't, because C is defined as 
> ```shared```.  Is there anything I can do to fix this?

Wait, is this a regression?

---------------------------------------------------------------------------------------

Up to      2.098.1: Success and no output
Since      2.099.1: Failure with output:
     -----
     onlineapp.d(7): Error: none of the overloads of template 
`object.opEquals` are callable using argument types 
`!()(shared(const(C)), shared(const(C)))`
     
/path/to/dmd.linux/dmd2/linux/bin64/../../src/druntime/import/object.d(269):        Candidate is: `opEquals(LHS, RHS)(LHS lhs, RHS rhs)`
       with `LHS = shared(const(C)),
            RHS = shared(const(C))`
       must satisfy the following constraint:
     `       is(LHS : const(Object))`
     -----


More information about the Digitalmars-d-learn mailing list