Hello, With the new ‘-Wunused-toplevel’ the compiler warns about unused module-local top-level variables [0].
It works well, but has the following limitations: - Public variables exported with ‘define-public’, ‘export’, or anything other than the ‘#:export’ option of ‘define-module’ is considered private, and thus possibly misdiagnosed as unused. This is because ‘export’ et al. are only evaluated at run-time, not at compile-time, unlike ‘define-module’. This is something we could change, though. - Local variables used only by a macro are incorrectly flagged as unused. Example: (define (bar) 'foo) (define-syntax baz (syntax-rules () ((_) (bar)))) Here ‘bar’ is incorrectly flagged as unused. This is because the definition of ‘baz’ expands to ‘(define baz (make-syntax-transformer ...))’ and this code doesn’t contain any literal ‘(toplevel-ref bar)’. Instead, the reference to ‘bar’ is buried in an opaque syntax object. Andy: any idea how to work around this? Thanks, Ludo’. [0] http://git.sv.gnu.org/cgit/guile.git/commit/?id=bcae9a98b0dd82b7be93e90134a01a03b44b4af7