GNU bug report logs - #62399
30.0.50; eglot + csharp-ts-mode, query pattern is malformed

Previous Next

Package: emacs;

Reported by: 牟 桐 <mou.tong <at> outlook.com>

Date: Thu, 23 Mar 2023 06:05:01 UTC

Severity: normal

Tags: patch

Found in version 30.0.50

To reply to this bug, email your comments to 62399 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#62399; Package emacs. (Thu, 23 Mar 2023 06:05:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to 牟 桐 <mou.tong <at> outlook.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 23 Mar 2023 06:05:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: 牟 桐 <mou.tong <at> outlook.com>
To: "bug-gnu-emacs <at> gnu.org" <bug-gnu-emacs <at> gnu.org>
Subject: 30.0.50; eglot + csharp-ts-mode, query pattern is malformed
Date: Thu, 23 Mar 2023 05:59:02 +0000

Hi there, I'm using csharp-ts-mode with eglot.

When My cursor stopped on a symbol, eglot will bold the text, which
works fine when I'm using `csharp-mode`.  But when I changed the major
mode to `csharp-ts-mode`, there will be the following error in the
minibuffer.

```
error in process filter: Query pattern is malformed: "Node type error at", 1060, "(qualified_name (identifier) @font-lock-type-face) (using_directive (identifier) @font-lock-type-face) (using_directive (name_equals (identifier) @font-lock-type-face)) (enum_declaration (identifier) @font-lock-type-face) (enum_member_declaration (identifier) @font-lock-variable-name-face) (interface_declaration (identifier) @font-lock-type-face) (struct_declaration (identifier) @font-lock-type-face) (record_declaration (identifier) @font-lock-type-face) (namespace_declaration (identifier) @font-lock-type-face) (base_list (identifier) @font-lock-type-face) (property_declaration type: (nullable_type) @font-lock-type-face name: (identifier) @font-lock-variable-name-face) (property_declaration type: (predefined_type) @font-lock-type-face name: (identifier) @font-lock-variable-name-face) (property_declaration type: (identifier) @font-lock-type-face name: (identifier) @font-lock-variable-name-face) (class_declaration (identifier) @font-lock-type-face) (constructor_declaration name: (_) @font-lock-type-face) (method_declaration type: [(identifier) (void_keyword)] @font-lock-type-face) (method_declaration type: (generic_name (identifier) @font-lock-type-face)) (method_declaration name: (_) @font-lock-function-name-face) (catch_declaration ((identifier) @font-lock-type-face)) (catch_declaration ((identifier) @font-lock-type-face (identifier) @font-lock-variable-name-face)) (variable_declaration (identifier) @font-lock-type-face) (variable_declaration (generic_name (identifier) @font-lock-type-face)) (variable_declarator (identifier) @font-lock-variable-name-face) (parameter type: (identifier) @font-lock-type-face) (parameter type: (generic_name (identifier) @font-lock-type-face)) (parameter name: (identifier) @font-lock-variable-name-face) (lambda_expression (identifier) @font-lock-variable-name-face) (declaration_expression type: (identifier) @font-lock-type-face) (declaration_expression name: (identifier) @font-lock-variable-name-face)", "Debug the query with `treesit-query-validate'"
```

Steps to reproduce:

1. `dotnet new console -o demo`
2. Use Emacs to open `demo/Program.cs`.
3. `M-x eglot` and put your cursor on `WriteLine` method.
4. Minibuffer error shows up.



In GNU Emacs 30.0.50 (build 2, x86_64-apple-darwin21.6.0, NS
appkit-2113.60 Version 12.6.3 (Build 21G419)) of 2023-03-17 built on
dalum.local
Repository revision: 0330cff65ae837e93ae4d059acf643734d16386d
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2113
System Description:  macOS 12.6.3

Configured using:
'configure --with-native-compilation=aot'

Configured features:
ACL DBUS GIF GLIB GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP
NOTIFY KQUEUE NS PDUMPER PNG RSVG SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM ZLIB

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

Major mode: C#

Minor modes in effect:
  global-avy-zh-mode: t
  avy-zh-mode: t
  shell-dirtrack-mode: t
  eglot--managed-mode: t
  flymake-mode: t
  subword-mode: t
  rainbow-delimiters-mode: t
  editorconfig-mode: t
  eyebrowse-mode: t
  diff-hl-flydiff-mode: t
  global-diff-hl-mode: t
  diff-hl-mode: t
  vertico-mode: t
  corfu-popupinfo-mode: t
  global-corfu-mode: t
  corfu-mode: t
  global-hl-todo-mode: t
  hl-todo-mode: t
  yas-global-mode: t
  yas-minor-mode: t
  global-evil-zh-mode: t
  evil-zh-mode: t
  global-evil-surround-mode: t
  evil-surround-mode: t
  evil-mode: t
  evil-local-mode: t
  winum-mode: t
  marginalia-mode: t
  auto-compile-on-load-mode: t
  auto-compile-on-save-mode: t
  override-global-mode: t
  pixel-scroll-precision-mode: t
  display-time-mode: t
  winner-mode: t
  electric-pair-mode: t
  global-auto-revert-mode: t
  save-place-mode: t
  global-so-long-mode: t
  delete-selection-mode: t
  recentf-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
  size-indication-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

Load-path shadows:
/Users/mou/.emacs.d/etc/abbrev hides /Applications/Emacs.app/Contents/Resources/lisp/abbrev

Features:
(shadow sort mail-extr emacsbug message yank-media puny rfc822 mml
mml-sec epa 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 cus-edit
cus-start cus-load help-fns ace-window avy-zh avy files-x shell
pcomplete cape-keyword cape pulse consult-xref consult-vertico consult
bookmark eglot external-completion array ert pp debug backtrace
find-func jsonrpc xref flymake-proc flymake imenu csharp-mode
c-ts-common cc-langs citre-lang-c cc-mode cc-fonts cc-guess cc-menus
cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs compile
text-property-search comint ansi-osc ansi-color jka-compr citre
citre-global emmet-mode web-mode disp-table time-date cap-words
superword subword rainbow-delimiters editorconfig package browse-url url
url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf url-util mailcap url-handlers url-parse auth-source eieio
eieio-core password-cache json map url-vars editorconfig-core
editorconfig-core-handle editorconfig-fnmatch eyebrowse format-spec
diff-hl-flydiff diff diff-hl face-remap vc-hg vc-git log-view pcvs-util
vc-dir ewoc vc vc-dispatcher diff-mode orderless vertico corfu-popupinfo
corfu hl-todo yasnippet init-lsp init-python init-dart init-web derived
init-lua init-js init-tex init-sexp init-chinese init-snippet
init-markup init-evil general evil-zh evil-surround evil
evil-keybindings evil-integration evil-maps evil-commands reveal
evil-jumps evil-command-window evil-search evil-ex evil-types
evil-macros evil-repeat evil-states evil-core advice evil-common
thingatpt rect evil-digraphs evil-vars init-irc init-reader init-misc
init-check flyspell ispell init-prog citre-config citre-lang-fileref
citre-tags citre-ctags citre-readtags citre-readtags-tables
citre-backend-interface citre-ui-peek color citre-ui-jump
citre-common-tag citre-common-util project treesit init-corfu
init-vertico init-vc init-edit winum dash edmacro kmacro byte-opt
marginalia zh-lib init-package no-littering compat auto-compile comp
comp-cstr warnings icons use-package use-package-ensure
use-package-delight use-package-diminish use-package-bind-key bind-key
use-package-core zh-lib-autoloads zenburn-theme-autoloads
yasnippet-autoloads yaml-autoloads xr-autoloads with-editor-autoloads
winum-autoloads wgrep-autoloads websocket-autoloads web-mode-autoloads
vundo-autoloads vertico-autoloads valign-autoloads treepy-autoloads
tomelr-autoloads toc-org-autoloads tao-theme-autoloads tablist-autoloads
subed-autoloads srcery-theme-autoloads spacemacs-theme-autoloads
solarized-theme-autoloads sinolor-themes-autoloads separedit-autoloads
search-dired-autoloads s-autoloads request-autoloads
rainbow-mode-autoloads rainbow-delimiters-autoloads
pyim-basedict-autoloads pyim-autoloads posframe-autoloads
popon-autoloads polymode-autoloads php-mode-autoloads
pdf-tools-autoloads ox-hugo-autoloads organic-green-theme-autoloads
orderless-autoloads nord-theme-autoloads no-littering-autoloads
monokai-theme-autoloads moe-theme-autoloads material-theme-autoloads
markdown-mode-autoloads marginalia-autoloads magit-autoloads
lua-mode-autoloads lsp-bridge-autoloads llama-autoloads
leuven-theme-autoloads kaolin-themes-autoloads htmlize-autoloads
hl-todo-autoloads gruvbox-theme-autoloads
green-is-the-new-black-theme-autoloads goto-chg-autoloads
git-modes-autoloads git-link-autoloads ghub-autoloads ggtags-autoloads
general-autoloads geiser-mit-autoloads geiser-guile-autoloads
geiser-autoloads forge-autoloads f-autoloads eyebrowse-autoloads
expand-region-autoloads evil-zh-autoloads evil-surround-autoloads
evil-nerd-commenter-autoloads evil-autoloads epkg-marginalia-autoloads
epkg-autoloads embark-autoloads emacsql-autoloads elfeed-org-autoloads
elfeed-autoloads ein-autoloads ef-themes-autoloads
editorconfig-autoloads edit-indirect-autoloads dracula-theme-autoloads
doom-themes-autoloads diff-hl-autoloads deferred-autoloads
dash-autoloads dart-mode-autoloads darkroom-autoloads
cyberpunk-theme-autoloads corfu-autoloads consult-autoloads
compat-autoloads color-theme-sanityinc-tomorrow-autoloads
color-theme-sanityinc-solarized-autoloads color-rg-autoloads
closql-autoloads citre-autoloads cape-autoloads borg-autoloads
avy-zh-autoloads avy-autoloads autothemer-autoloads
auto-yasnippet-autoloads auto-compile-autoloads
atom-one-dark-theme-autoloads async-autoloads
anti-zenburn-theme-autoloads anaphora-autoloads ample-theme-autoloads
all-the-icons-autoloads alect-themes-autoloads cl-extra help-mode
ace-window-autoloads cl-seq borg loaddefs-gen generate-lisp-file
lisp-mnt radix-tree info bytecomp byte-compile init-gui pixel-scroll
cua-base subr-x init-ibuffer ibuf-macs init-org init-dired dired-aux
dired-x dired dired-loaddefs init-funcs rx easy-mmode cl-macs gv pcase
init-modeline time init-utils whitespace winner ring midnight elec-pair
autorevert filenotify saveplace so-long delsel recentf tree-widget
wid-edit cl-loaddefs cl-lib 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 dbusbind kqueue cocoa ns
lcms2 multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 517832 1137169)
(symbols 48 30694 170)
(strings 32 112265 58855)
(string-bytes 1 4241702)
(vectors 16 53907)
(vector-slots 8 1086581 480366)
(floats 8 276 1067)
(intervals 56 2153 1335)
(buffers 984 25))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62399; Package emacs. (Thu, 23 Mar 2023 06:10:02 GMT) Full text and rfc822 format available.

Message #8 received at 62399 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: 牟 桐 <mou.tong <at> outlook.com>, 62399 <at> debbugs.gnu.org
Subject: Re: bug#62399: 30.0.50; eglot + csharp-ts-mode, query pattern is
 malformed
Date: Thu, 23 Mar 2023 08:09:41 +0200
Hi!

On 23/03/2023 07:59, 牟 桐 wrote:
> 2. Use Emacs to open `demo/Program.cs`.

Could you attach the file demo/Program.cs here?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62399; Package emacs. (Thu, 23 Mar 2023 06:26:01 GMT) Full text and rfc822 format available.

Message #11 received at 62399 <at> debbugs.gnu.org (full text, mbox):

From: 牟 桐 <mou.tong <at> outlook.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>, "62399 <at> debbugs.gnu.org"
 <62399 <at> debbugs.gnu.org>
Subject: 回复: bug#62399: 30.0.50; eglot + csharp-ts-mode, query pattern is malformed
Date: Thu, 23 Mar 2023 06:25:35 +0000
[Message part 1 (text/plain, inline)]
Ah sorry, here it is:

``` csharp-ts-mode
Console.WriteLine("Hello, World!");
```

(yes, just one line...)

The lsp I’m using is `csharp-ls`, I guess it won’t affect this issue.

But just in case, the way to install `csharp-ls` is

   dotnet tool install csharp-ls -g

________________________________
发件人: DG <raaahh <at> gmail.com> 代表 Dmitry Gutov <dgutov <at> yandex.ru>
发送时间: 2023年3月23日 14:09
收件人: 牟 桐 <mou.tong <at> outlook.com>; 62399 <at> debbugs.gnu.org <62399 <at> debbugs.gnu.org>
主题: Re: bug#62399: 30.0.50; eglot + csharp-ts-mode, query pattern is malformed

Hi!

On 23/03/2023 07:59, 牟 桐 wrote:
> 2. Use Emacs to open `demo/Program.cs`.

Could you attach the file demo/Program.cs here?
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62399; Package emacs. (Thu, 23 Mar 2023 07:58:02 GMT) Full text and rfc822 format available.

Message #14 received at 62399 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: 牟 桐 <mou.tong <at> outlook.com>,
 "62399 <at> debbugs.gnu.org" <62399 <at> debbugs.gnu.org>,
 Theodor Thornhill <theo <at> thornhill.no>
Subject: Re: bug#62399: 回复: bug#62399: 30.0.50; eglot + csharp-ts-mode, query pattern is malformed
Date: Thu, 23 Mar 2023 09:57:36 +0200
On 23/03/2023 08:25, 牟 桐 wrote:
> Ah sorry, here it is:
> 
> ``` csharp-ts-mode
> Console.WriteLine("Hello, World!");
> ```
> 
> (yes, just one line...)

Thanks! I guess the problem will show up with any file.

And I can repro after installing the c-sharp grammar from master.

> The lsp I’m using is `csharp-ls`, I guess it won’t affect this issue.
> 
> But just in case, the way to install `csharp-ls` is
> 
>     dotnet tool install csharp-ls -g

A language server was not necessary to reproduce this, but thanks.

This is the patch that worked for me:

diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el
index 47cd13e7fdb..e2df08f4dae 100644
--- a/lisp/progmodes/csharp-mode.el
+++ b/lisp/progmodes/csharp-mode.el
@@ -832,7 +832,7 @@ csharp-ts-mode--font-lock-settings

      (constructor_declaration name: (_) @font-lock-type-face)

-     (method_declaration type: [(identifier) (void_keyword)] 
@font-lock-type-face)
+     (method_declaration type: [(identifier) (predefined_type)] 
@font-lock-type-face)
      (method_declaration type: (generic_name (identifier) 
@font-lock-type-face))
      (method_declaration name: (_) @font-lock-function-name-face)


Looks like a change was made to the grammar fairly recently which made 
(void_keyword) not valid in the above context: 
https://github.com/tree-sitter/tree-sitter-c-sharp/commit/18a531d4c133d9f1b3796b9bead7681ba3382fb3

Cc'ing the author of that mode for a second opinion. But I guess we'll 
need a runtime check just like we added for java-ts-mode recently.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62399; Package emacs. (Thu, 23 Mar 2023 16:21:02 GMT) Full text and rfc822 format available.

Message #17 received at 62399 <at> debbugs.gnu.org (full text, mbox):

From: 牟 桐 <mou.tong <at> outlook.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>, "62399 <at> debbugs.gnu.org"
 <62399 <at> debbugs.gnu.org>, Theodor Thornhill <theo <at> thornhill.no>
Subject: bug#62399: 30.0.50; eglot + csharp-ts-mode, query pattern is malformed
Date: Thu, 23 Mar 2023 16:19:59 +0000
[Message part 1 (text/plain, inline)]
Thanks, I tried your patch and now it works fine on my computer now.

Hope to see it got merged soon 😉

发件人: Dmitry Gutov<mailto:dgutov <at> yandex.ru>
发送时间: 2023年3月23日 15:57
收件人: 牟 桐<mailto:mou.tong <at> outlook.com>; 62399 <at> debbugs.gnu.org<mailto:62399 <at> debbugs.gnu.org>; Theodor Thornhill<mailto:theo <at> thornhill.no>
主题: Re: bug#62399: 回复: bug#62399: 30.0.50; eglot + csharp-ts-mode, query pattern is malformed

On 23/03/2023 08:25, 牟 桐 wrote:
> Ah sorry, here it is:
>
> ``` csharp-ts-mode
> Console.WriteLine("Hello, World!");
> ```
>
> (yes, just one line...)

Thanks! I guess the problem will show up with any file.

And I can repro after installing the c-sharp grammar from master.

> The lsp I’m using is `csharp-ls`, I guess it won’t affect this issue.
>
> But just in case, the way to install `csharp-ls` is
>
>     dotnet tool install csharp-ls -g

A language server was not necessary to reproduce this, but thanks.

This is the patch that worked for me:

diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el
index 47cd13e7fdb..e2df08f4dae 100644
--- a/lisp/progmodes/csharp-mode.el
+++ b/lisp/progmodes/csharp-mode.el
@@ -832,7 +832,7 @@ csharp-ts-mode--font-lock-settings

       (constructor_declaration name: (_) @font-lock-type-face)

-     (method_declaration type: [(identifier) (void_keyword)]
@font-lock-type-face)
+     (method_declaration type: [(identifier) (predefined_type)]
@font-lock-type-face)
       (method_declaration type: (generic_name (identifier)
@font-lock-type-face))
       (method_declaration name: (_) @font-lock-function-name-face)


Looks like a change was made to the grammar fairly recently which made
(void_keyword) not valid in the above context:
https://github.com/tree-sitter/tree-sitter-c-sharp/commit/18a531d4c133d9f1b3796b9bead7681ba3382fb3

Cc'ing the author of that mode for a second opinion. But I guess we'll
need a runtime check just like we added for java-ts-mode recently.

[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62399; Package emacs. (Mon, 04 Sep 2023 19:57:02 GMT) Full text and rfc822 format available.

Message #20 received at 62399 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Theodor Thornhill <theo <at> thornhill.no>,
 "62399 <at> debbugs.gnu.org" <62399 <at> debbugs.gnu.org>,
 牟 桐 <mou.tong <at> outlook.com>
Subject: Re: bug#62399: 回复: bug#62399: 30.0.50; eglot + csharp-ts-mode, query pattern is malformed
Date: Mon, 4 Sep 2023 12:56:48 -0700
Dmitry Gutov <dgutov <at> yandex.ru> writes:

> On 23/03/2023 08:25, 牟 桐 wrote:
>> Ah sorry, here it is:
>> ``` csharp-ts-mode
>> Console.WriteLine("Hello, World!");
>> ```
>> (yes, just one line...)
>
> Thanks! I guess the problem will show up with any file.
>
> And I can repro after installing the c-sharp grammar from master.
>
>> The lsp I’m using is `csharp-ls`, I guess it won’t affect this issue.
>> But just in case, the way to install `csharp-ls` is
>>     dotnet tool install csharp-ls -g
>
> A language server was not necessary to reproduce this, but thanks.
>
> This is the patch that worked for me:

It doesn't seem like this was ever installed?  Should it be?

> diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el
> index 47cd13e7fdb..e2df08f4dae 100644
> --- a/lisp/progmodes/csharp-mode.el
> +++ b/lisp/progmodes/csharp-mode.el
> @@ -832,7 +832,7 @@ csharp-ts-mode--font-lock-settings
>
>       (constructor_declaration name: (_) @font-lock-type-face)
>
> -     (method_declaration type: [(identifier) (void_keyword)]
>       @font-lock-type-face)
> +     (method_declaration type: [(identifier) (predefined_type)]
> @font-lock-type-face)
>       (method_declaration type: (generic_name (identifier)
>       @font-lock-type-face))
>       (method_declaration name: (_) @font-lock-function-name-face)
>
>
> Looks like a change was made to the grammar fairly recently which made
> (void_keyword) not valid in the above context:
> https://github.com/tree-sitter/tree-sitter-c-sharp/commit/18a531d4c133d9f1b3796b9bead7681ba3382fb3
>
> Cc'ing the author of that mode for a second opinion. But I guess we'll need a
> runtime check just like we added for java-ts-mode recently.




Added tag(s) patch. Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 12 Sep 2023 00:05:02 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 277 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.