www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24027] New: error: instantiated from here:

https://issues.dlang.org/show_bug.cgi?id=24027

          Issue ID: 24027
           Summary: error: instantiated from here: `maxElement!("a.a",
                    A[])`
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: mingwu gmail.com

```
$ 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
```

--
Jul 02 2023