Issue 22136 - [REG 2.097.1] hashOf failed to compile because of different inheritance order
Summary: [REG 2.097.1] hashOf failed to compile because of different inheritance order
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: druntime (show other issues)
Version: D2
Hardware: All Windows
: P1 regression
Assignee: Eduard Staniloiu
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2021-07-22 09:54 UTC by Heromyth
Modified: 2022-03-08 16:27 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Heromyth 2021-07-22 09:54:59 UTC
Compiler: DMD 2.097.1

Error: 

```
../../src/druntime/import/core/internal/hash.d(612,33): Error: expected 2 arguments for `getMember` but had 1
source/app.d(30,26): Error: template instance `core.internal.hash.hashOf!(Bug!string)` error instantiating
```

Test Code:

```
import std.range;

interface IObject {
    size_t toHash() @trusted nothrow;
}

interface Bug(E) : InputRange!E, IObject {

}

interface OK(E) : IObject, InputRange!E {
}


void main() {

    {
        Bug!string s;
        size_t t = hashOf(s);
    }

    
    {
        OK!string s;
        size_t t = hashOf(s);
    }    
}
```
Comment 1 Tejas_Garhewal 2021-09-17 03:37:23 UTC
Seems to be a regression.

Works fine on dmd 2.097.0 (https://run.dlang.io/gist/cb1ed3bd5db4cf5b99e26454116b969a?args=-h)

Works fine on ldc2 1.25.0 (based on 2.095.1)
Comment 2 Eduard Staniloiu 2021-12-08 18:07:08 UTC
I did some digging on this, and the bug actually stems from the following issue

```
interface IObject
{
   size_t toHash() @trusted nothrow;
}

interface Dummy {}
interface Bug(E) : Dummy, IObject {}                                                                                                                                                                                                                                                                                                                               interface OK(E) : IObject, Dummy {}

static assert(is(immutable OK!string* : immutable IObject*))); // OK
static assert(is(immutable Bug!string* : immutable IObject*))); // fails
```

It appears that the order affects the is expression and
the `is(immutable T* : immutable U*)` check is done inside the `hashOf` function.

I'm currently investigating this in dmd.
Comment 3 Dlang Bot 2021-12-08 19:36:36 UTC
@edi33416 created dlang/dmd pull request #13404 "Fix Issue 22136 - [REG 2.097.1] hashOf failed to compile because of d…" fixing this issue:

- Fix Issue 22136 - [REG 2.097.1] hashOf failed to compile because of different inheritance order

https://github.com/dlang/dmd/pull/13404
Comment 4 Dlang Bot 2021-12-21 09:14:35 UTC
dlang/dmd pull request #13404 "Fix Issue 22136 - [REG 2.097.1] hashOf failed to compile because of d…" was merged into stable:

- 289394fab4695d3f601767ea004f9c1737880395 by Eduard Staniloiu:
  Fix Issue 22136 - [REG 2.097.1] hashOf failed to compile because of different inheritance order

https://github.com/dlang/dmd/pull/13404
Comment 5 Dlang Bot 2022-03-03 11:04:00 UTC
dlang/dmd pull request #13745 "Revert "Fix Issue 22136 - [REG 2.097.1] hashOf failed to compile because of d…"" was merged into stable:

- 646fe4e97e1dae3e083ae461931f123f036bd4cf by Nathan Sashihara:
  Revert "Fix Issue 22136 - [REG 2.097.1] hashOf failed to compile because of different inheritance order (#13404)"
  
  This reverts commit 646ec178ffa13cf596026dae4217fdad27ad777c.

https://github.com/dlang/dmd/pull/13745
Comment 6 Dlang Bot 2022-03-08 16:27:11 UTC
dlang/dmd pull request #13785 "merge stable" was merged into master:

- da491b8ada5f557a222c369f7f1bb481ca10880e by Nathan Sashihara:
  Revert "Fix Issue 22136 - [REG 2.097.1] hashOf failed to compile because of different inheritance order (#13404)" (#13745)
  
  This reverts commit 646ec178ffa13cf596026dae4217fdad27ad777c.

https://github.com/dlang/dmd/pull/13785