Bug 21094 – [REG2.078] Array equality for struct with class member and opCast and alias this
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-07-30T11:03:45Z
Last change time
2022-08-22T12:31:54Z
Keywords
industry
Assigned to
No Owner
Creator
johanengelen
Comments
Comment #0 by johanengelen — 2020-07-30T11:03:45Z
This testcase does not compile since 2.078:
```
class C {
int a;
}
struct S {
bool isValid;
C fib;
inout(C) get() pure @safe @nogc nothrow inout {
return isValid ? fib : C.init;
}
T opCast(T : C)() const { return null; }
alias get this;
}
auto foo(S[] lhs, S[] rhs) {
return lhs == rhs;
}
```
The error:
/druntime/src/core/internal/array/equality.d(101): Error: template instance `opCast!(Object)` does not match template declaration `opCast(T : C)()`
/druntime/src/core/internal/array/equality.d(101): Error: template instance `opCast!(Object)` does not match template declaration `opCast(T : C)()`
/druntime/src/core/internal/array/equality.d(102): Error: template instance `opCast!bool` does not match template declaration `opCast(T : C)()`
/druntime/src/core/internal/array/equality.d(102): Error: template instance `opCast!(Object)` does not match template declaration `opCast(T : C)()`
weka/lib/comparison.d(38): Error: template instance `core.internal.array.equality.__equals!(S, S)` error instantiating
It appears to be fixed by https://github.com/dlang/druntime/pull/3142 , but please add this extra testcase. Thanks.
Comment #1 by dlang-bot — 2022-08-22T12:31:26Z
dlang/dmd pull request #14379 "Add test case for issue 21094" was merged into master:
- efa069f93274011db774cde1ffc18acd8c259619 by RazvanN7:
Add test case for issue 21094
https://github.com/dlang/dmd/pull/14379
Comment #2 by razvan.nitu1305 — 2022-08-22T12:31:54Z