[Issue 17941] arity (and probably others) only consider the first lexically present function
https://issues.dlang.org/show_bug.cgi?id=17941 Iain Buclaw changed: What|Removed |Added Priority|P1 |P4 --
[Issue 17941] arity (and probably others) only consider the first lexically present function
https://issues.dlang.org/show_bug.cgi?id=17941 Simen Kjaeraas changed: What|Removed |Added Component|dmd |phobos OS|Linux |All --- Comment #4 from Simen Kjaeraas --- (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. --
[Issue 17941] arity (and probably others) only consider the first lexically present function
https://issues.dlang.org/show_bug.cgi?id=17941 --- Comment #3 from dechcaudron+dlang.issue.track...@protonmail.com --- > a real solution would allow people to indicate which overload they're > interested in Maybe allow something of the sort static assert(arity!fun(int) == 1); static assert(arity!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. --
[Issue 17941] arity (and probably others) only consider the first lexically present function
https://issues.dlang.org/show_bug.cgi?id=17941 Simen Kjaeraas changed: What|Removed |Added CC||dechcaudron+dlang.issue.tra ||ck...@protonmail.com --- Comment #2 from Simen Kjaeraas --- *** Issue 18314 has been marked as a duplicate of this issue. *** --
[Issue 17941] arity (and probably others) only consider the first lexically present function
https://issues.dlang.org/show_bug.cgi?id=17941 Simen Kjaeraas changed: What|Removed |Added CC||simen.kja...@gmail.com --- Comment #1 from Simen Kjaeraas --- This happens for all templates in std.traits that deal with properties of functions. Making the templates fail when presented with an under-specified overload set would be a breaking change, but documenting the behavior is definitely worth it. Phobos currently does not have good tools for working with overload sets - __traits(getOverloads) is what we've got, and finding a specific overload is manual work. In order to fix that part of the problem, I've created getOverloads and overloadFor: https://github.com/dlang/phobos/pull/5818 --
[Issue 17941] arity (and probably others) only consider the first lexically present function
https://issues.dlang.org/show_bug.cgi?id=17941 Ketmar Dark changed: What|Removed |Added CC||ket...@ketmar.no-ip.org --