Subject: bug#78392: 31.0.50; eglot breaks on xref-find-definitions

From: "[email-masked]" <[email-masked]>
Date: Mon, 12 May 2025 06:29:15 +0000

Currently, when building from latest Emacs ToT, activating `eglot-mode`
in any C++ file using `clangd` and attempting to call
`xref-find-definitions` on any definition results in the following error
being triggered:

```
Opening input file: Is a directory, c:/Users/sonictk/tmp
```

Where the `.cpp` file is in the given directory. Tried building Emacs
using a build from a month-ish ago to find where the regression first
occurred and it still had the issue present, even when doing `make
distclean` and then `make bootstrap` after re-running `./configure`.

`toggle-debug-on-error` gives me:

```
Debugger entered--Lisp error: (file-error "Opening input file" "Is a directory" "c:/Users/sonictk/tmp")
  eglot--xref-make-match(#("Baz" 0 3 (face font-lock-function-name-face fontified t)) "file:///c:/Users/sonictk/tmp/test2.cpp" (:end (:character 11 :line 23) :start (:character 8 :line 23)))
  #f(compiled-function (loc-or-loc-link) #<bytecode 0x413eb090fd3d661>)((:range (:end (:character 11 :line 23) :start (:character 8 :line 23)) :uri "file:///c:/Users/sonictk/tmp/test2.cpp"))
  eglot--lsp-xrefs-for-method(:textDocument/definition)
  #f(compiled-function (backend id) #<bytecode -0x10624bec505aa107>)(eglot "LSP identifier at point")
  apply(#f(compiled-function (backend id) #<bytecode -0x10624bec505aa107>) eglot "LSP identifier at point")
  xref-backend-definitions(eglot "LSP identifier at point")
  #f(compiled-function () #<bytecode 0x558a9dc3551d156>)()
  xref-show-definitions-buffer(#f(compiled-function () #<bytecode 0x558a9dc3551d156>) ((window . #<window 9 on test2.cpp>) (display-action) (auto-jump)))
  xref--show-defs(#f(compiled-function () #<bytecode 0x558a9dc3551d156>) nil)
  xref--find-definitions("LSP identifier at point" nil)
  xref-find-definitions("LSP identifier at point")
  funcall-interactively(xref-find-definitions "LSP identifier at point")
  command-execute(xref-find-definitions)
```

In GNU Emacs 31.0.50 (build 1, x86_64-w64-mingw32) of 2025-05-11 built
 on CDW-AQRHE1HHT39
Repository revision: 64eb60bd91dbeed458d5a410e6dc9ab4e9e0a10e
Repository branch: HEAD
Windowing system distributor 'Microsoft Corp.', version 10.0.19045
System Description: Microsoft Windows 10 Enterprise (v10.0.2009.19045.5737)

Configured using:
 'configure --without-pop --with-imagemagick --without-compress-install
 -without-dbus --with-gnutls --with-json --with-tree-sitter
 --without-gconf --with-rsvg --without-gsettings --with-mailutils
 --with-native-compilation --with-modules --with-xml2 --with-wide-int
 'CFLAGS=-O3 -ggdb -fno-math-errno -funsafe-math-optimizations
 -fno-finite-math-only -fno-trapping-math -freciprocal-math
 -fno-rounding-math -fno-signaling-nans -fassociative-math
 -fno-signed-zeros -frename-registers -funroll-loops -mtune=native
 -march=native -fomit-frame-pointer -fallow-store-data-races
 -fno-semantic-interposition -floop-parallelize-all
 -ftree-parallelize-loops=4'
 PKG_CONFIG_PATH=/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig'

Configured features:
ACL GIF GMP GNUTLS HARFBUZZ IMAGEMAGICK JPEG LCMS2 LIBXML2 MODULES
NATIVE_COMP NOTIFY W32NOTIFY PDUMPER PNG RSVG SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XPM ZLIB

Important settings:
  value of $LC_CTYPE: en_US.UTF-8
  value of $LANG: ENU
  locale-coding-system: cp1252

Major mode: C++//l

Minor modes in effect:
  eglot-inlay-hints-mode: t
  eglot--managed-mode: t
  flymake-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
  minibuffer-regexp-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
  abbrev-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug lisp-mnt message mailcap yank-media puny
dired dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068
epg-config gnus-util mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils time-date cl-extra eglot tree-widget
wid-edit external-completion jsonrpc xref flymake thingatpt project diff
diff-mode track-changes easy-mmode ert pp ewoc debug backtrace help-mode
find-func filenotify warnings compile text-property-search comint
ansi-osc ansi-color ring pcase url-util url-parse auth-source cl-seq
eieio eieio-core cl-macs icons password-cache json subr-x map byte-opt
gv url-vars imenu comp-run bytecomp byte-compile comp-common rx cc-mode
cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars
cc-defs cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc paren
electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
touch-screen dos-w32 ls-lisp term/w32-nt disp-table term/w32-win w32-win
w32-vars 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 w32notify w32 lcms2 multi-tty move-toolbar make-network-process
tty-child-frames native-compile emacs)

Memory information:
((conses 16 576487 112162) (symbols 48 13713 0)
 (strings 32 43491 4466) (string-bytes 1 1432645) (vectors 16 51034)
 (vector-slots 8 835660 10348) (floats 8 61 76) (intervals 56 678 13)
 (buffers 1064 17))