Add a Warning on unused parameter in a function
|Assignee:||Alain Prouté||% Done:|
If a function parameter is never used, it would be nice that the compiler outputs a warning about this.
#1 Updated by Alain Prouté over 10 years ago
- Status changed from New to Assigned
Of course, this would only concern top level functions, not functions defined by the arrow |->. For example, in the widgets, it is often the case that a callback does not use its arguments. Furthermore, all functions taking a unique argument of type One do not use it in general. This argument is nevertheless mandatory for delaying execution.
This makes also a problem for example for the function forget defined in predefined.anubis. We don't want to have a warning at each use of forget.
However, it may be the case that forget is the only case of unused argument really useful.
A solution may be to send a warning only if the function is top level and has at least two arguments. What do you think of that ?
#2 Updated by Cédric RICARD over 10 years ago
May be we can use a way like C/C++ compilers: when we want to explicitly not use a argument, we simply remove its name into the parameter declaration (so there is only its type).
I don't know if it's possible without breaking the Anubis grammar parser...