Multiple functions, same signature

Luís Marques luis at luismarques.eu
Wed Jul 11 16:43:09 UTC 2018


On Wednesday, 11 July 2018 at 16:21:26 UTC, Jacob Carlborg wrote:
> You'll get an error if you call "foo".

I understand that. Still seems like something that the frontend 
should detect, unless there's a good use case for multiple 
(re)definitions. If I had to guess, it's probably to support 
generic code which may have the same or different type modifiers 
applied, possibly resulting in a collision.

In my specific case, due to the functions being manipulated by 
generic code, it led to a harder to diagnose bug, since the 
functions weren't called directly (or at all, of course). 
Instead, the openmethods library builds a list of dispatch 
targets, but it didn't detect at compile-time that the targets 
were redundant, which led to a *runtime* error, and a harder to 
diagnose situation. openmethods.d could be changed to deal with 
that, but it seems like the frontend would be the ideal place to 
check it, unless D should really support redundant functions.


More information about the Digitalmars-d mailing list