unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#73526: 31.0.50; [FR] warn about unreachable code
@ 2024-09-28 10:23 Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; only message in thread
From: Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-09-28 10:23 UTC (permalink / raw)
  To: 73526



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





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-09-28 10:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-28 10:23 bug#73526: 31.0.50; [FR] warn about unreachable code Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).