Project

General

Profile

Actions

Feature #23

open

Add a Warning on unused parameter in a function

Feature #23: Add a Warning on unused parameter in a function

Added by Anonymous almost 19 years ago. Updated over 18 years ago.

Status:
New
Priority:
Low
Assignee:
Category:
Compiler
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Platform:
Resolution:
Triage Stage:

Description

If a function parameter is never used, it would be nice that the compiler outputs a warning about this.

Updated by Alain Prouté almost 19 years ago Actions #1

  • 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 ?

Updated by Anonymous almost 19 years ago Actions #2

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

Updated by Alain Prouté almost 19 years ago Actions #3

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.

Updated by Alain Prouté almost 19 years ago Actions #4

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.

Updated by Alain Prouté over 18 years ago Actions #5

  • Status changed from Assigned to New
Actions

Also available in: PDF Atom