Subject: bug#71863: closed (Re: bug#71863: 31.0.50; Wrong argument type for treesit-query-range in treesit-update-ranges)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 15 Jul 2024 06:20:02 +0000

Your bug report

#71863: 31.0.50; Wrong argument type for treesit-query-range in treesit-update-ranges

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
71863: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71863
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#71863: 31.0.50; Wrong argument type for treesit-query-range in treesit-update-ranges
From: Yuan Fu <[email-masked]>
To: Eli Zaretskii <[email-masked]>
Cc: Noah Peart <[email-masked]>, [email-masked]
Date: Sun, 14 Jul 2024 23:18:18 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

> On Jul 6, 2024, at 10:35 PM, Eli Zaretskii <[email-masked]> wrote:
> 
>> From: Yuan Fu <[email-masked]>
>> Date: Sat, 6 Jul 2024 13:50:10 -0700
>> Cc: Noah Peart <[email-masked]>,
>> [email-masked]
>> 
>> 
>> 
>>> On Jul 6, 2024, at 1:38 AM, Eli Zaretskii <[email-masked]> wrote:
>>> 
>>>> From: Noah Peart <[email-masked]>
>>>> Date: Sun, 30 Jun 2024 16:12:06 -0400
>>>> 
>>>> I just noticed this after building latest Emacs. In
>>>> `treesit-update-ranges`, during redisplay, the first argument to
>>>> `treesit-query-range` is a tree-sitter language symbol, not a node.
>>>> 
>>>> At treesit.el:760
>>>> 
>>>>   (let* ((host-lang (treesit-query-language query))
>>>>          (parser (treesit-parser-create language))
>>>>          (old-ranges (treesit-parser-included-ranges parser))
>>>>>>> host-lang isnt a node
>>>>          (new-ranges (treesit-query-range
>>>>                       host-lang query beg end offset))
>>>> 
>>>> This causes a an error in modes that have set `treesit-range-settings`
>>>> eg., `js-ts-mode`:
>>>> 
>>>>> Error muted by safe_call: (treesit--font-lock-mark-ranges-to-fontify
>>>>> ((1 . 940)) #<treesit-parser for javascript>) signaled
>>>>> (wrong-type-argument treesit-node-p javascript) Error during
>>>>> redisplay: (jit-lock-function 1) signaled (wrong-type-argument
>>>>> treesit-node-p javascript)
>>>> 
>>>> And in `syntax-propertize-function`, for example in `ruby-ts-mode`,
>>>> 
>>>>> QuitError muted by safe_call: (internal--syntax-propertize 46)
>>>>> signaled (wrong-type-argument treesit-node-p ruby) 
>>> 
>>> Yuan, could you please look into this issue?
>> 
>> This is a bug I introduced on emacs-30 and later fixed. So once emacs-30 is merged into master the issue should go away. Sorry for the trouble :-(
> 
> When did you fix it on emacs-30?  The merges to master happen very
> frequently lately; the last one was yesterday.  Could it be that this
> is already fixed?

I checked with master (with php-ts-mode) and it’s working fine. So I’m closing this report. Fell free to reopen if there’re problems.

Yuan

Subject: 31.0.50; Wrong argument type for treesit-query-range in treesit-update-ranges
From: Noah Peart <[email-masked]>
To: [email-masked]
Date: Sun, 30 Jun 2024 16:12:06 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

I just noticed this after building latest Emacs. In
`treesit-update-ranges`, during redisplay, the first argument to
`treesit-query-range` is a tree-sitter language symbol, not a node.

At treesit.el:760

    (let* ((host-lang (treesit-query-language query))
           (parser (treesit-parser-create language))
           (old-ranges (treesit-parser-included-ranges parser))
>>> host-lang isnt a node
           (new-ranges (treesit-query-range
                        host-lang query beg end offset))

This causes a an error in modes that have set `treesit-range-settings`
eg., `js-ts-mode`:

> Error muted by safe_call: (treesit--font-lock-mark-ranges-to-fontify
> ((1 . 940)) #<treesit-parser for javascript>) signaled
> (wrong-type-argument treesit-node-p javascript) Error during
> redisplay: (jit-lock-function 1) signaled (wrong-type-argument
> treesit-node-p javascript)

And in `syntax-propertize-function`, for example in `ruby-ts-mode`,

> QuitError muted by safe_call: (internal--syntax-propertize 46)
> signaled (wrong-type-argument treesit-node-p ruby)

In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.33, cairo version 1.16.0) of 2024-06-30 built on nverno-XPS-8940
Repository revision: 7c8d4e96ba6db19bdca20a87bafed024a84eb517
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101004
System Description: Ubuntu 22.04.4 LTS

Configured using:
 'configure --prefix=/usr/local --with-modules --with-tree-sitter
 --with-threads --with-x-toolkit=gtk3 --with-xwidgets --with-gnutls
 --with-json --with-mailutils --with-jpeg --with-png --with-rsvg
 --with-tiff --with-xml2 --with-xpm --with-imagemagick CC=gcc-12
 CXX=gcc-12'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ
IMAGEMAGICK JPEG LCMS2 LIBSELINUX LIBXML2 MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM XWIDGETS
GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: JavaScript

Minor modes in effect:
  tooltip-mode: t
  global-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

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 text-property-search time-date mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils cl-seq
typescript-ts-mode js c-ts-common json subr-x map byte-opt gv bytecomp
byte-compile imenu cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles
cc-align cc-engine cc-vars cc-defs treesit cl-loaddefs cl-lib rmc
iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd touch-screen 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 xwidget-internal dbusbind inotify lcms2 dynamic-setting
system-font-setting font-render-setting cairo gtk x-toolkit xinput2 x
multi-tty move-toolbar make-network-process native-compile emacs)

Memory information:
((conses 16 104084 13132) (symbols 48 8580 0) (strings 32 24764 2578)
 (string-bytes 1 884578) (vectors 16 14855)
 (vector-slots 8 188214 9981) (floats 8 28 203) (intervals 56 852 0)
 (buffers 992 12))