[Issue 17941] arity (and probably others) only consider the first lexically present function
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jan 28 15:20:24 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=17941
Simen Kjaeraas <simen.kjaras at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|dmd |phobos
OS|Linux |All
--- Comment #4 from Simen Kjaeraas <simen.kjaras at gmail.com> ---
(In reply to dechcaudron+dlang.issue.tracking from comment #3)
> Maybe allow something of the sort
>
> static assert(arity!fun(int) == 1);
> static assert(arity!gun(int, int) == 2);
arity is an interesting case here, since it's hard to get the correct overload
without knowing the arity already. :p
The PR mentioned above would get the correct arity this way:
static assert(arity!(overloadFor!(fun, int)) == 1);
static assert(arity!(overloadFor!(gun, int, int)) == 2);
> I had reported this as a Phobos issue (see above), but since it has been
> marked as a duplicate for a dmd one, there's not much I can do. Compiler
> stuff is still magic to me, I'm afraid.
Fixing the issue in DMD would break a *lot* of code, and so isn't really
feasible. I'm pretty sure it's not really desirable either, since the new
semantics would be at least as weird as what we have.
You could say the root issue is in DMD - templates operate on the first element
when passed an overload set. The problem can however be ameliorated in Phobos,
by giving programmers a way to specify which overload they mean.
--
More information about the Digitalmars-d-bugs
mailing list