Feature #23

Add a Warning on unused parameter in a function

Added by Cédric RICARD over 10 years ago. Updated almost 10 years ago.

Status:NewStart date:
Priority:LowDue date:
Assignee:Alain Prouté% Done:


Target version:1.x
Platform: Triage Stage:


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...

#3 Updated by Alain Prouté over 10 years ago

What do you think of this: just use an underscore as the name for an intentionnally non used argument (for all sorts of functions) ?

As a consequence, a warning will be sent if the argument has another name and is not used.

#4 Updated by Alain Prouté over 10 years ago

Remark that we may apply the same method to resurgent symbols in conditionals (indeed, cases in conditionals are some kind of inline functions, head then body being equivalent to head |-> body). But maybe it's too many constraints.

#5 Updated by Alain Prouté almost 10 years ago

  • Status changed from Assigned to New

Also available in: Atom PDF

Redmine Appliance - Powered by TurnKey Linux