IFTI reflection would be nice

Stefan Koch uplink.coder at googlemail.com
Sun Jul 26 19:00:03 UTC 2020


On Sunday, 26 July 2020 at 17:30:40 UTC, Avrina wrote:
> On Sunday, 26 July 2020 at 16:36:43 UTC, Adam D. Ruppe wrote:
>> [...]
>
> That should probably be an error, there's no reason that should 
> work at all. It can't select one based on the type, it 
> shouldn't select any, and it looks like it just selects the 
> first one.
>
> You can do this which is more type safe, but again, it should 
> an ambiguous error. There's no reason it should be picking 
> string over int.
>
> import std.stdio;
>
> void foo(string) { writeln("foo(string)"); }
> void foo(int)    { writeln("foo(int)"); }
>
> void main() {
> 	void function(float) a = &foo;
> }
>
> Error: cannot implicitly convert expression & foo of type void 
> function(string _param_0) to void function(float)

The reason is the other of definition.
But the int overload first and the error should go away.


More information about the Digitalmars-d mailing list