On 8/10/22 11:26 AM, Ruby The Roobster wrote:
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))`
-----
Yes. It's a druntime regression.
In the compiler, instances shared classes are now treated as if the
variables were declared `shared`. Prior to this, they were just `C`.
Druntime was not updated to reflect this.
A related bug: https://issues.dlang.org/show_bug.cgi?id=23140
-Steve