Feature Request: Style warning on 'suspicious' constant/symbol

Bug #1836382 reported by Wilfredo Velázquez-Rodríguez
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Opinion
Undecided
Unassigned

Bug Description

A user error I see come up here and there, especially among beginners, is something along the lines of:

(defun foo (&key a b c)
  (list c a b))

(let ((bar 0) (baz 1) (quux 2))
  (foo :a bar)
       :b baz
       :c quux)

Where clearly parens lining up was incorrect.
This occurs in any other places with progn-style behaviour, except notably, tagbody.

This class of bug would be eliminated if SBCL were to notice usage of a constant (here :b and :c) or a symbol (here baz) being in a position where their value is completely unused as in the above, and signal a style warning along the lines of

style-warning:
  Suspicious use of constant :B in noop position

I'm struggling to come up with a better name than 'noop' or 'unimpactful', but the general idea should be clear.
Additionally, in reference to tagbody, it would be useful to signal a style-warning on referenced tags, which would accomplish the equivalent 'fix' for the user-error in those cases.

Clearly this is low priority, but I believe it'd be very useful and I imagine it's relatively low effort to implement.

For posterity, this is as of SBCL 1.5.4

Revision history for this message
Paul F. Dietz (paul-f-dietz) wrote :

One would have to be sure that macros only very rarely expand to such code.

Revision history for this message
Douglas Katzman (dougk) wrote :

There's no syntax to say that tagbody tags are ignorable, so it would produce too many warnings.
I don't think this is worth doing.

Changed in sbcl:
status: New → Opinion
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.