Unused variable warning and unused variable notation
Nobody has claimed this yet.
- Dominant language
- Racket
- Stars
- 601
- Forks
- 74
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 5
Description
A feature I really wish to see in Rhombus is static warning about unused variables, as these are usually mistakes. DrRacket in a sense has this feature already via the tooltip "no bound occurrences". Racket Mode makes this even more explicit by highlighting these unused variables.
However, there are also legitimate unused variables. It would be annoying to see warnings for these legitimate cases. Several languages solve this problem by adding a special notation to indicate unused variables, usually by using identifier _ or identifier prefixed with _. Editors / tools then can recognize these identifiers and don't report them as unused.
Note that this is not just a convention. It needs a support from the language. For example, the following code should work:
(define (foo _ a _ b)
(+ a b))
but currently Racket fails with:
define: duplicate argument identifier in: _
Similarly, the following code should work:
(define-values (_ a) (values 1 2))
(define-values (b _) (values 1 2))
(+ a b)
but currently Racket fails with:
module: identifier already defined in: _
There's also a question about how to make the notation customizable. It should be possible to create a new language where this unused variable notation is disabled, for example.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files or tests. Start by tracing how Rhombus handles function arguments and define-values bindings, then determine how repeated or prefixed unused-variable notation and language-level customization should work; done means the examples compile without duplicate-identifier errors and unused-variable warnings distinguish intentional bindings.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100