Subject: bug#76730: 29.3; gv-define-setter defect

From: Devon Sean McCullough <[email-masked]>
Date: Mon, 03 Mar 2025 21:16:22 -0600

Spurious byte compiler errors when called for effect:

(decf (overlay-end (make-overlay 1 2)))
-->
(let* ((v (make-overlay 1 2)))
   (progn
     (move-overlay v (overlay-start v) (- (overlay-end v) 1))
     (- (overlay-end v) 1)))

because the redundant second (- (overlay-end v) 1) gets
Warning: value returned from (- (overlay-end v) 1) is unused

A better expansion such as

(let* ((v (make-overlay 1 2))
        (s (- (overlay-end v) 1)))
   (progn
     (move-overlay v (overlay-start v) s)
     s))

looks ok and should pacify the byte compiler.

		Peace
			--Devon

P.S.  Could be worse than mere spurious warnings:
lisp/emacs-lisp/gv.el

(gv-define-setter overlay-end (store ov)
   `(progn (move-overlay ,ov (overlay-start ,ov) ,store) ,store))

the expansion correctly evaluates OV only once,
yet incorrectly evaluates STORE twice!
Too clever for its own good?

P.P.S.  I won't ask why the warning points to the top-level form
rather than the offending line.

In GNU Emacs 29.3 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60
  Version 10.14.6 (Build 18G9323)) of 2024-03-24 built on
  builder10-14.lan
Windowing system distributor 'Apple', version 10.3.1671
System Description:  Mac OS X 10.14.6

Configured using:
  'configure --with-ns '--enable-locallisppath=/Library/Application
  Support/Emacs/${version}/site-lisp:/Library/Application
  Support/Emacs/site-lisp' --with-modules 'CFLAGS=-DFD_SETSIZE=10000
  -DDARWIN_UNLIMITED_SELECT' --with-x-toolkit=no'

Configured features:
ACL GLIB GMP GNUTLS JPEG JSON LIBXML2 MODULES NOTIFY KQUEUE NS PDUMPER
PNG RSVG SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER ZLIB

Important settings:
   value of $LANG: en_US.UTF-8
   locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
   text-scale-mode: t
   tooltip-mode: t
   global-eldoc-mode: t
   eldoc-mode: t
   show-paren-mode: t
   electric-indent-mode: t
   mouse-wheel-mode: t
   tool-bar-mode: t
   menu-bar-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   font-lock-mode: t
   blink-cursor-mode: t
   line-number-mode: t
   indent-tabs-mode: t
   transient-mark-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util time-date subr-x mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils pp cl-macs cl cl-print
byte-opt gv bytecomp byte-compile debug backtrace find-func trace
cl-extra shortdoc text-property-search help-fns radix-tree help-mode
cl-loaddefs cl-lib format-spec face-remap rmc iso-transl tooltip cconv
eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type
elisp-mode mwheel term/ns-win ns-win ucs-normalize mule-util
term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads kqueue cocoa ns multi-tty make-network-process emacs)

Memory information:
((conses 16 59178 7115)
  (symbols 48 6664 0)
  (strings 32 19075 1819)
  (string-bytes 1 548309)
  (vectors 16 12773)
  (vector-slots 8 187827 13307)
  (floats 8 133 93)
  (intervals 56 471 3)
  (buffers 984 15))