Bug 24027 – error: instantiated from here: `maxElement!("a.a", A[])`

Status
RESOLVED
Resolution
FIXED
Severity
blocker
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2023-07-03T00:41:16Z
Last change time
2023-07-15T15:18:19Z
Keywords
pull
Assigned to
No Owner
Creator
mw

Comments

Comment #0 by mingwu — 2023-07-03T00:41:16Z
``` $ cat maxElementbug.d import std; class A { int a; } void main() { A[] arr; maxElement!"a.a"(arr); } $ dmd maxElementbug.d /usr/include/dmd/phobos/std/algorithm/searching.d(1329): Error: none of the overloads of template `object.get` are callable using argument types `!()(A)` /usr/include/dmd/druntime/import/object.d(3423): Candidates are: `get(K, V)(inout(V[K]) aa, K key, lazy inout(V) defaultValue)` /usr/include/dmd/druntime/import/object.d(3430): `get(K, V)(inout(V[K])* aa, K key, lazy inout(V) defaultValue)` /usr/include/dmd/phobos/std/algorithm/searching.d(3783): Error: template instance `std.algorithm.searching.extremum!("a.a", "a > b", A[])` error instantiating maxElementbug.d(9): instantiated from here: `maxElement!("a.a", A[])` $ dmd --version DMD64 D Compiler v2.104.0 Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved written by Walter Bright ``` BTW, ldc2 with v2.102.2 is fine. ``` ldc2 --version LDC - the LLVM D compiler (1.32.2): based on DMD v2.102.2 and LLVM 15.0.7 ```
Comment #1 by default_357-line — 2023-07-03T02:49:19Z
I think this is a dupe of https://issues.dlang.org/show_bug.cgi?id=23993 . Seems to be fixed on master. This was my fault, sorry - the rewrite to use `Rebindable` had to handle array cases separately. See https://github.com/dlang/phobos/pull/8764 . In my defense, that type was designed badly.
Comment #2 by default_357-line — 2023-07-03T03:00:37Z
Oh no, I see - this is the other other special case of `Rebindable`. I'll make a PR for stable.
Comment #3 by dlang-bot — 2023-07-03T03:05:16Z
@FeepingCreature created dlang/phobos pull request #8777 "Fix issue 24027: specialcase `Rebindable` for `class` as well." fixing this issue: - Fix issue 24027: specialcase `Rebindable` for `class` as well. Non-mutable `class` is another case where `Rebindable` just silently aliases itself away. Don't sweat that this looks ugly - this is fixed on `master` via the `Rebindable2` rewrite https://github.com/dlang/phobos/pull/8768 https://github.com/dlang/phobos/pull/8777
Comment #4 by dlang-bot — 2023-07-03T23:31:41Z
dlang/phobos pull request #8777 "Fix issue 24027: Instead of a bunch of special-cases, just check that `Rebindable` did in fact alias itself away." was merged into stable: - 24ec18b2686effb0abbde6de61b590a5941e0609 by FeepingCreature: Fix issue 24027: Instead of a bunch of special-cases, just check that `Rebindable` did in fact alias itself away. This looks ugly, but it's just for the `stable` branch - this is fixed on `master` via the `Rebindable2` rewrite https://github.com/dlang/phobos/pull/8768 https://github.com/dlang/phobos/pull/8777
Comment #5 by dlang-bot — 2023-07-15T15:18:19Z
dlang/phobos pull request #8782 "merge stable" was merged into master: - dfcbee7056318734aaa88d9051369463eb94c637 by FeepingCreature: Fix issue 24027: Instead of a bunch of special-cases, just check that `Rebindable` did in fact alias itself away. This looks ugly, but it's just for the `stable` branch - this is fixed on `master` via the `Rebindable2` rewrite https://github.com/dlang/phobos/pull/8768 https://github.com/dlang/phobos/pull/8782