~xerool/fennel-ls#24: 
`(case ... [a] ...)` should not trigger unused definition warning

Not sure how you feel about this one, it's different to https://todo.sr.ht/~xerool/fennel-ls/23 ([a a] == (= a1 a2))

The following,

(case x
  [any-non-nil] (do ...)))

gives an unused definition warning, but the existence of a binding is usage, its implicitly checking for non-nil.

Status
REPORTED
Submitter
~rktjmp
Assigned to
No-one
Submitted
8 months ago
Updated
5 months ago
Labels
needs-design

~xerool 8 months ago*

This one is a tricky one. I think the lint can be very useful sometimes, but in the cases where the lint falsely applies, it is very annoying because there's no good way to suppress it, because renaming the identifier to _any-non-nil also changes the meaning of the expression.

~xerool 8 months ago

See also (lambda [x] (body-that-does-not-use-x)), which currently does not give a warning but probably should

~xerool 8 months ago

I have a potential solution but I think people may not like it.

Imagine if fennel-ls did not warn for any identifiers that start with !. Then, you could suppress these particular patterns by prefixing your identifier with !. For example {:foo !} would be a pattern that checks that foo exists, but also draws attention to the fact that the binding is intentionally unused. Similarly, you could match a list of length >= 3 with a pattern like [!1 !2 !3].

Thoughts?

~xerool referenced this from #26 7 months ago

Register here or Log in to comment, or comment via email.