Subject: 29.1; "A bug in the function debug."

From: Lewis Creary <[email-masked]>
Date: Mon, 23 Oct 2023 05:41:46 +0000 (UTC)

While I was trying to diagnose a bug in the function displayed just belowwith the help of the function debug, the interim values of the lisp variables shown were inconsistent with the code being debugged.  For example, when called with the argument 5, the first element of the remainder list should be 1 (5 divided by 2 leaves a remainder of 1).  However, the fn debug claims that the variable `rmdr-list' has the first element 0.  This is just wrong!  And it has nothing to do with the problem being debugged.
(defun dec-to-bin (n)  (let ((dividend n)        (rmdr-list nil)        (stop-sw nil)        (numstr "") )    (while ((and (>= dividend 0) (not stop-sw)))       (setq dividend (/ dividend 2)              rmdr-list (append (list (% dividend 2))                                               rmdr-list) )       (if (= dividend 0)            (setq stop-sw t)) )       (debug) )    (while rmdr-list      (setq numstr (concat numstr (number-to-string                                          (car rmdr-list)))             rmdr-list (cdr rmdr-list) ) )    (string-to-number numstr) ))-----------------------------------------------------In GNU emacs 29.1 (build 2, x86_64-w64-mingw32) of 2023-08-02 built on AVALONWindowing system distributor 'Microsoft Corp.', version 10.0.22621System Description: Microsoft Windows 10 Home (v10.0.2009.22621.2428)Configured using: 'configure --with-modules --without-dbus --with-native-compilation=aot --without-compress-install --with-tree-sitter CFLAGS=-O2'
Configured features:ACL GIF GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMPNOTIFY W32NOTIFY PDUMPER PNG RSVG SOUND SQLITE3 THREADS TIFFTOOLKIT_SCROLL_BARS TREE_SITTER WEBP XPM ZLIB
(NATIVE_COMP present but libgccjit not available)
Important settings:  value of $LANG: ENU  locale-coding-system: cp1252
Major mode: Lisp Interaction
Minor modes in effect:  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