template instance does not match template declaration

Paul Backus snarwin at gmail.com
Fri Feb 25 23:17:14 UTC 2022

On Friday, 25 February 2022 at 23:05:00 UTC, kdevel wrote:
> It seems the template parameter f becomes not aliased to 
> model.read in the presence of the selective import. Bug or 
> feature?

I'd call this a bug. Currently, selective imports are implemented 
using `alias`es under the hood, which means that the compiler 
sees your `model` module as having *two* overloads of `read`:

alias read = std.file.read; // from selective import

int read (string filename)
     // etc.

When you pass an overload set to a template that isn't written to 
handle multiple overloads, it will usually just choose whichever 
overload comes first in the source code. And since the `public 
import` statement comes earlier in your source file than the 
definition of `read`, the `std.file.read` alias is the one that 
gets chosen when you write `Parameters!read`.

More information about the Digitalmars-d-learn mailing list