GNU bug report logs -
#73526
31.0.50; [FR] warn about unreachable code
Previous Next
Full log
View this message in rfc822 format
Feature request: warn about unreachable code in Emacs Lisp.
Unreachable code means Lisp forms that occur in positions that can never
be reached, so these forms are never evaluated. The simplest cases of
unreachable code are code that is only evaluated after some form that
never returns (such no-return forms include signal and throw calls, as
well as while loops with a never-nil test).
Unreachable code often indicates a programmer mistake, and never
improves (or otherwise affects) the program's behavior in any way.
So it's helpful to warn about it. Clang and Go provide such warnings,
for example.
Emacs sources include many occurrences of such unreachable code.
For example, in lisp/mail/uudecode.el we find:
--8<---------------cut here---------------start------------->8---
(cond
(done)
((> 0 remain)
(error "uucode line ends unexpectedly")
(setq done t)) <---- Unreachable!
...)
--8<---------------cut here---------------end--------------->8---
In lisp/gnus/nndir.el we see an example of a clear mistake that produces
easily detectable unreachable code:
--8<---------------cut here---------------start------------->8---
(or err "No such file or directory: %s" nndir-directory)
^ <---- Unreachable!
--8<---------------cut here---------------end--------------->8---
Thanks,
Eshel
This bug report was last modified 226 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.