digitalmars.D.learn - Array Wierdness
- Ruby The Roobster (15/15) Aug 10 2022 Take the following code:
- Ruby The Roobster (17/32) Aug 10 2022 Wait, is this a regression?
- Steven Schveighoffer (7/44) Aug 10 2022 Yes. It's a druntime regression.
- Ruby The Roobster (4/8) Aug 10 2022 Funnily enough, I came across this when trying to fix that same
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?
Aug 10 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))` -----
Aug 10 2022
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: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 -SteveTake 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))` -----
Aug 10 2022
On Wednesday, 10 August 2022 at 15:50:45 UTC, Steven Schveighoffer wrote:On 8/10/22 11:26 AM, Ruby The Roobster wrote: [SNIP] A related bug: https://issues.dlang.org/show_bug.cgi?id=23140 -SteveFunnily enough, I came across this when trying to fix that same bug.
Aug 10 2022