[Issue 17263] Issue diagnostic if mandatory template parameter is missing
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Nov 18 10:54:18 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=17263
RazvanN <razvan.nitu1305 at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |razvan.nitu1305 at gmail.com
--- Comment #4 from RazvanN <razvan.nitu1305 at gmail.com> ---
Hi Ali,
Now the diagnostic is:
test2.d(4): Error: none of the overloads of template
`std.algorithm.iteration.map` are callable using argument types `!()(int[],
void)`
/home/razvann/Dlang/dmd/generated/linux/release/64/../../../../../phobos/std/algorithm/iteration.d(436):
Candidate is: `map(fun...)`
with `fun = ()`
must satisfy the following constraint:
` fun.length >= 1`
I know it's not what you expected but isn't this better?
I am afraid that the actual error ("You forgot `!`") cannot be outputted
because when the template is instantiated we are in the semantic phase where we
no longer know whether the ! was present or not. In other words, we cannot know
just by looking at the AST if the user provided template instance was `[1,
2].map(i => i);` or `[1, 2].map!()(i => i);`. So. I think that this is the best
we could probably do in this case.
--
More information about the Digitalmars-d-bugs
mailing list