www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22824] New: alias template parameter bound to wrong symbol

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

          Issue ID: 22824
           Summary: alias template parameter bound to wrong symbol (Error:
                    template instance does not match template declaration)
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: kdevel vogtner.de

```model.d
module model; // model.d
import std.file : read; // this line provokes the error

int read (string filename)
{
   import std.file;
   auto data = std.file.read (filename);
   return 0;
}
```

```main.d
module main; // main.d
import std.traits;
import model;

void main ()
{
   alias Q = Parameters!(read);
}
```

$ dmd -i main
main.d(7): Error: template instance `model.Parameters!(read)` does not match
template declaration `Parameters(func...)`
  with `func = (read)`
  must satisfy the following constraint:
`       isCallable!func`

As explained in [1] the template parameter is bound to std.file.read instead of
module.read.

[1] http://forum.dlang.org/thread/htnakhxqoxqeduzzgdbl forum.dlang.org
    template instance does not match template declaration

--
Feb 25 2022