Bug 22136 – [REG 2.097.1] hashOf failed to compile because of different inheritance order

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2021-07-22T09:54:59Z
Last change time
2022-03-08T16:27:11Z
Keywords
pull
Assigned to
Eduard Staniloiu
Creator
Heromyth

Comments

Comment #0 by bitworld — 2021-07-22T09:54:59Z
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 by scienticman — 2021-09-17T03:37:23Z
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 by edi33416 — 2021-12-08T18:07:08Z
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 by dlang-bot — 2021-12-08T19:36:36Z
@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 by dlang-bot — 2021-12-21T09:14:35Z
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 by dlang-bot — 2022-03-03T11:04:00Z
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 by dlang-bot — 2022-03-08T16:27:11Z
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