Unused lexical functions not (DECLARE IGNORE)'d don't report a STYLE-WARNING as for variables.

Bug #841260 reported by Jean-Philippe Paradis on 2011-09-04
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

What I do:
(flet ((foo ())))
=> NIL

What happens:
Compilation and evaluation proceed without a STYLE-WARNING.

What I expected to happen:
I expected a STYLE-WARNING.

It's already well-established that an unused LET binding results in a STYLE-WARNING unless it's been (DECLARE IGNORE)'d. The above situation is exactly analogous except it takes place in the function namespace, so the same behavior should apply.

If we look at CLHS IGNORE we see it's indeed possible to (DECLARE IGNORE) (or IGNORABLE) a function, reinforcing the idea that the same behavior (a STYLE-WARNING) should apply.

SBCL version: 1.0.51
uname -a: Linux dynamorph 2.6.32-33-generic #72-Ubuntu SMP Fri Jul 29 21:08:37 UTC 2011 i686 GNU/Linux


Nikodemus Siivola (nikodemus) wrote :

They are reported. What you're experiencing is the either *evalutor-mode* :interpret, or EVAL muffling of style-warnings from compiling the toplevel form prior to its execution.

CL-USER> (compile nil '(lambda () (flet ((foo () ())))))
; in: LAMBDA ()
; note: deleting unused function
; compilation unit finished
; printed 1 note
#<FUNCTION (LAMBDA ()) {10030DE0D9}>

Changed in sbcl:
status: New → Invalid

I didn't go out of my way to change *EVALUATOR-MODE* to :interpret and I verified that it's indeed set to :compile.

As for "EVAL muffling of style-warnings from compiling the toplevel form prior to its execution", I'm not sure exactly what that means, but given that entering (let ((foo nil))) in the REPL produces a "STYLE-WARNING: The variable FOO is defined but never used", I'm positive that entering (flet ((foo ()))) in the REPL ought to produce a "STYLE-WARNING: The function FOO is defined but never used" since these are completely analogous situations in all relevant respects (the only difference being that one binding is happening in the variable namespace while the other happens in the function namespace).

I understand that there might be technical/historical reasons why the behaviors differ, but from a user's perspective, I don't see how the discrepancy might be justified.

(And btw I consider a NOTE to be quite different than a STYLE-WARNING.)

Nikodemus Siivola (nikodemus) wrote :

On reflection, I don't see why functions and variables should no be treated equivalently. Would need to double-check CLHS, though.

Changed in sbcl:
importance: Undecided → Wishlist
status: Invalid → Triaged
tags: added: compiler-ir1 easy
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers