Subject: bug#73358: 29.4; eglot-rename falsely claims success

From: Joost Kremers <[email-masked]>
Date: Thu, 19 Sep 2024 09:05:25 +0200

I tried to use 'eglot-rename' to rename a variable to a name that 
already existed in the relevant function. The change was not 
applied but Eglot nonetheless reported "[eglot] Edit successful!".

This was in a Python buffer, using python-ts-mode and basedpyright 
(v1.17.1) as language server. The relevant code snippet:

```
def main(): 
    sizes = [100, 1000, 10000] results: dict[str, list[float]] = { 
        "Linear search": [], "Binary search": [], "Interpolation 
        search": [], 
    } for size in sizes: 
        seq: list[int] = sorted([random.randint(0, 10000) for _ in 
        range(size)]) x = random.choice(arr) results["Linear 
        search"].append(measure_time(linear_search, arr, x)) 
        results["Binary 
        search"].append(measure_time(binary_search, arr, x)) 
        results["Interpolation search"].append( 
            measure_time(interpolation_search, arr, x) 
        ) 
```

Note the 'seq' variable in the first line of the for loop, and the 
'arr' variable in the three '.append' invocations. With point on 
the first 'arr', calling eglot-rename and giving 'seq' as the new 
name, Eglot refuses to rename the three occurrences of 'arr' 
(which makes sense, given that a variable with that name obviously 
already exists), but still reports success.

(Note that there is no problem if the 'seq' above is also 'arr'. 
Then renaming works fine.) 
In GNU Emacs 29.4 (build 1, x86_64-pc-linux-gnu, GTK+ Version 
3.24.43, cairo version 1.18.0) System Description: Arch Linux 
Configured using: 
 'configure --with-pgtk --with-native-compilation=aot 
 --sysconfdir=/etc --prefix=/usr --libexecdir=/usr/lib 
 --with-tree-sitter --localstatedir=/var --with-cairo 
 --disable-build-details --with-harfbuzz --with-libsystemd 
 --with-modules 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe 
 -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat 
 -Werror=format-security -fstack-clash-protection -fcf-protection 
 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g 
 -ffile-prefix-map=/build/emacs/src=/usr/src/debug/emacs 
 -flto=auto' 'LDFLAGS=-Wl,-O1 -Wl,--sort-common -Wl,--as-needed 
 -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs -flto=auto' 
 'CXXFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt 
 -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat 
 -Werror=format-security -fstack-clash-protection -fcf-protection 
 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer 
 -Wp,-D_GLIBCXX_ASSERTIONS -g 
 -ffile-prefix-map=/build/emacs/src=/usr/src/debug/emacs 
 -flto=auto'' 
Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS 
GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSYSTEMD LIBXML2 
MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PGTK PNG RSVG SECCOMP 
SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP 
XIM GTK3 ZLIB Important settings: 
  value of $LANG: en_GB.UTF-8 locale-coding-system: utf-8-unix 
 
Major mode: Python  Minor modes in effect: 
  combobulate-mode: t indent-bars--ts-mode: t indent-bars-mode: t 
  subword-mode: t consult-denote-mode: t pyvenv-mode: t 
  display-fill-column-indicator-mode: t flyspell-mode: t 
  flycheck-indicator-mode: t global-flycheck-eglot-mode: t 
  flycheck-eglot-mode: t flycheck-posframe-mode: t flycheck-mode: 
  t eldoc-box-hover-mode: t minions-mode: t doom-modeline-mode: t 
  which-key-mode: t global-atomic-chrome-edit-mode: t 
  marginalia-mode: t all-the-icons-completion-mode: t 
  company-prescient-mode: t prescient-persist-mode: t 
  vertico-multiform-mode: t eros-mode: t hexl-follow-ascii: t 
  eglot-booster-mode: t eglot-inlay-hints-mode: t 
  eglot--managed-mode: t vertico-mode: t global-diff-hl-mode: t 
  diff-hl-mode: t global-git-commit-mode: t 
  global-treesit-auto-mode: t which-function-mode: t 
  yas-minor-mode: t global-org-modern-mode: t outline-minor-mode: 
  t denote-menu-bar-mode: t shell-dirtrack-mode: t hl-line-mode: t 
  goggles-mode: t company-quickhelp-mode: t 
  company-quickhelp-local-mode: t global-company-mode: t 
  company-mode: t csv-field-index-mode: t override-global-mode: t 
  server-mode: t repeat-mode: t winner-mode: t electric-pair-mode: 
  t recentf-mode: t delete-selection-mode: t apheleia-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 column-number-mode: t 
  line-number-mode: t transient-mark-mode: t 
  auto-composition-mode: t auto-encryption-mode: t 
  auto-compression-mode: t auto-save-visited-mode: t 
 
Load-path shadows: ~/src/parsebib/parsebib hides 
/home/joost/.emacs.d/elpa/parsebib-20230228.1530/parsebib 
~/.emacs.d/lisp/custom hides /usr/share/emacs/29.4/lisp/custom 
/home/joost/.emacs.d/elpa/transient-20240918.1138/transient hides 
/usr/share/emacs/29.4/lisp/transient 
/home/joost/.emacs.d/elpa/jsonrpc-1.0.25/jsonrpc hides 
/usr/share/emacs/29.4/lisp/jsonrpc 
/home/joost/.emacs.d/elpa/eglot-1.17/eglot hides 
/usr/share/emacs/29.4/lisp/progmodes/eglot 
/home/joost/.emacs.d/elpa/eldoc-1.15.0/eldoc hides 
/usr/share/emacs/29.4/lisp/emacs-lisp/eldoc  Features: (shadow 
guess-language mail-extr emacsbug expand-region 
yaml-mode-expansions subword-mode-expansions text-mode-expansions 
the-org-mode-expansions python-el-fgallina-expansions 
html-mode-expansions er-basic-expansions expand-region-core 
expand-region-custom apheleia apheleia-rcs apheleia-dp 
apheleia-formatters apheleia-utils apheleia-log 
apheleia-formatter-context view markdown-mode ace-window avy 
visual-fill-column misearch multi-isearch combobulate 
combobulate-json combobulate-yaml combobulate-css 
combobulate-js-ts combobulate-python combobulate-html 
combobulate-query savehist scheme combobulate-ui 
combobulate-display combobulate-ztree combobulate-contrib 
multiple-cursors mc-separate-operations rectangular-region-mode 
mc-mark-pop mc-edit-lines mc-hide-unmatched-lines-mode 
mc-mark-more sgml-mode facemenu mc-cycle-cursors 
multiple-cursors-core rect combobulate-envelope 
combobulate-manipulation combobulate-procedure 
combobulate-navigation combobulate-misc combobulate-interface 
combobulate-rules combobulate-settings indent-bars-ts indent-bars 
cap-words superword subword vc-git consult-flycheck consult-denote 
consult pyvenv mule-util display-fill-column-indicator flyspell 
ispell flycheck-indicator flycheck-ledger flycheck-eglot 
flycheck-posframe flycheck eldoc-box jk-input-methods quail 
solarized-light-theme solarized-theme solarized solarized-faces 
go-translate gt-text-utility gt-engine-echo gt-engine-libre 
gt-engine-chatgpt gt-engine-youdao gt-engine-stardict 
gt-engine-deepl gt-engine-google-rpc gt-engine-google 
gt-engine-bing gt-extension gt-faces gt-core gt-httpx wgrep-ag 
wgrep csv2ledger vterm bookmark term disp-table ehelp vterm-module 
term/xterm xterm ielm minions doom-modeline doom-modeline-segments 
doom-modeline-env doom-modeline-core shrink-path f nerd-icons 
nerd-icons-faces nerd-icons-data nerd-icons-data-mdicon 
nerd-icons-data-flicon nerd-icons-data-codicon 
nerd-icons-data-devicon nerd-icons-data-sucicon 
nerd-icons-data-wicon nerd-icons-data-faicon 
nerd-icons-data-powerline nerd-icons-data-octicon 
nerd-icons-data-pomicon nerd-icons-data-ipsicon which-key 
atomic-chrome iimage image+ image-file image-converter marginalia 
all-the-icons-completion company-prescient prescient char-fold 
orderless vertico-multiform dockerfile-mode sh-script smie 
executable impatient-mode htmlize jupyter python-pytest edebug 
eros macrostep checkdoc paredit dape hexl gdb-mi gud eglot-booster 
eglot external-completion jsonrpc flymake-proc flymake diff ert 
debug backtrace org-linenote vertico projectile lisp-mnt grep 
ibuf-ext ibuffer ibuffer-loaddefs ag vc-svn compile find-dired s 
diff-hl log-view vc-dir ewoc vc vc-dispatcher diff-mode git-commit 
with-editor log-edit pcvs-util add-log magit-mode benchmark 
magit-git magit-base magit-section cursor-sensor crm autorevert 
aggressive-indent nswbuff finder-inf yaml-mode yaml treesit-auto 
reftex reftex-loaddefs reftex-vars which-func imenu tab-jump-out 
yasnippet-snippets yasnippet company-org-block org-modern 
org-settings org-clock ob-jupyter jupyter-tramp tramp-cache 
time-stamp jupyter-server jupyter-server-kernel jupyter-rest-api 
url-http url-auth url-gw nsm jupyter-org-extensions 
jupyter-org-client jupyter-repl jupyter-widget-client websocket 
bindat simple-httpd jupyter-client jupyter-kernel jupyter-monads 
jupyter-messages hmac-def jupyter-mime jupyter-kernelspec 
jupyter-env jupyter-base eieio-base ob-sqlite ob-sql ob-shell 
ob-clojure ob-python python treesit ol-w3m org-tempo tempo 
ol-rmail ol-mhe ol-irc ol-info ol-gnus nnselect gnus-art mm-uu 
mml2015 mm-view mml-smime smime gnutls dig gnus-sum gnus-group 
gnus-undo gnus-start gnus-dbus gnus-cloud nnimap nnmail 
mail-source utf7 nnoo gnus-spec gnus-int gnus-range message 
sendmail yank-media rfc822 mml mml-sec epa derived epg rfc6068 
epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231 
rfc2047 rfc2045 ietf-drums mailabbrev gmm-utils mailheader 
gnus-win ol-eww eww thingatpt shr pixel-fill kinsoku svg puny 
mm-url gnus nnheader gnus-util text-property-search mail-utils 
range mm-util mail-prsvr ol-doi org-link-doi ol-docview doc-view 
filenotify jka-compr image-mode exif ol-bibtex ol-bbdb org-element 
org-persist xdg org-id org-refile avl-tree dom org ob ob-tangle 
ob-ref ob-lob ob-table ob-exp org-macro org-src ob-comint 
org-pcomplete org-list org-footnote org-faces org-entities 
noutline outline ob-emacs-lisp ob-core ob-eval org-cycle org-table 
ol org-fold org-fold-core org-keys oc org-loaddefs find-func 
cal-menu calendar cal-loaddefs org-version org-compat org-macs 
transient compat compat-30 denote dired dired-loaddefs tramp 
tramp-loaddefs trampver tramp-integration tramp-compat shell 
pcomplete comint ansi-osc parse-time format-spec ansi-color 
mixed-pitch face-remap biblio biblio-download biblio-dissemin 
biblio-ieee biblio-hal biblio-dblp biblio-crossref biblio-arxiv 
timezone biblio-doi biblio-core let-alist url-queue url-file ido 
hl-line bibtex iso8601 time-date adaptive-wrap goggles comp 
comp-cstr warnings rx pulse color posframe hydra lv 
use-package-bind-key company-quickhelp pos-tip all-the-icons 
all-the-icons-faces data-material data-weathericons data-octicons 
data-fileicons data-faicons data-alltheicons company-keywords 
company-etags etags fileloop xref project company-gtags 
company-dabbrev-code company-dabbrev company-ipa company-files 
company-clang company-cmake company-semantic company-template 
company-css company-capf company use-package-ensure whitespace 
literate-scratch jk-functions advice csv-mode sort dash eshell 
esh-cmd generator esh-ext esh-opt esh-proc esh-io esh-arg 
esh-module esh-groups esh-util files-x notifications dbus xml 
use-package-core cl-extra help-mode edmacro kmacro bind-key server 
repeat winner ring elec-pair recentf tree-widget delsel help-at-pt 
cus-edit pp cus-load icons wid-edit 
all-the-icons-completion-autoloads all-the-icons-autoloads 
apheleia-autoloads easy-mmode async-autoloads avy-autoloads 
boxquote-autoloads breadcrumb-autoloads citar-autoloads 
citeproc-autoloads clojure-mode-autoloads company-auctex-autoloads 
auctex-autoloads tex-site company-box-autoloads 
company-prescient-autoloads company-quickhelp-autoloads 
consult-denote-autoloads consult-flycheck-autoloads corg-autoloads 
csv-mode-autoloads dape-autoloads denote-autoloads 
devdocs-browser-autoloads diff-hl-autoloads docker-autoloads 
dockerfile-mode-autoloads doom-modeline-autoloads 
eglot-booster-autoloads eldoc-box-autoloads 
embark-consult-autoloads consult-autoloads embark-autoloads 
eros-autoloads expand-region-autoloads 
flycheck-clj-kondo-autoloads flycheck-eglot-autoloads 
eglot-autoloads eldoc-autoloads go-translate-autoloads 
goggles-autoloads gptel-autoloads guess-language-autoloads 
hydra-autoloads ialign-autoloads impatient-mode-autoloads 
htmlize-autoloads indent-bars-autoloads company-autoloads 
js2-mode-autoloads json-process-client-autoloads jsonian-autoloads 
jsonrpc-autoloads jupyter-autoloads kivy-mode-autoloads 
ledger-mode-autoloads literate-scratch-autoloads lv-autoloads 
macrostep-autoloads magit-autoloads magit-section-autoloads 
marginalia-autoloads markdown-mode-autoloads minions-autoloads 
multiple-cursors-autoloads nerd-icons-autoloads numpydoc-autoloads 
nushell-ts-mode-autoloads orderless-autoloads 
org-linenote-autoloads org-modern-autoloads paredit-autoloads 
parsebib-autoloads pdf-tools-autoloads pos-tip-autoloads 
posframe-autoloads prescient-autoloads projectile-autoloads 
python-pytest-autoloads realgud-autoloads 
realgud-recursive-autoloads loc-changes-autoloads 
load-relative-autoloads f-autoloads simple-httpd-autoloads 
sly-overlay-autoloads sly-autoloads solarized-theme-autoloads 
string-inflection-autoloads tab-jump-out-autoloads 
tablist-autoloads test-simple-autoloads tide-autoloads 
flycheck-autoloads dash-autoloads track-changes-autoloads 
transient-autoloads treesit-auto-autoloads vertico-autoloads 
vterm-autoloads vundo-autoloads web-mode-autoloads 
websocket-autoloads which-key-autoloads with-editor-autoloads info 
compat-autoloads yaml-autoloads yaml-mode-autoloads 
yasnippet-snippets-autoloads yasnippet-autoloads zmq-autoloads 
package browse-url url url-proxy url-privacy url-expand 
url-methods url-history url-cookie generate-lisp-file url-domsuf 
url-util mailcap url-handlers url-parse auth-source cl-seq eieio 
eieio-core cl-macs password-cache json subr-x map byte-opt gv 
bytecomp byte-compile url-vars cl-loaddefs cl-lib pcase rmc 
iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook 
vc-hooks lisp-float-type elisp-mode mwheel term/pgtk-win pgtk-win 
term/common-win pgtk-dnd 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 dbusbind inotify 
dynamic-setting system-font-setting font-render-setting cairo gtk 
pgtk lcms2 multi-tty make-network-process native-compile emacs) 
Memory information: ((conses 16 1077432 142895) 
 (symbols 48 62716 43) (strings 32 337444 17754) (string-bytes 1 
 9972758) (vectors 16 131005) (vector-slots 8 3276102 238845) 
 (floats 8 1944 690) (intervals 56 4610 9280) (buffers 984 32)) 

-- 
Joost Kremers
Life has its moments