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

From: Yuan Fu <[email-masked]>
Date: Sat, 6 Jul 2024 13:50:10 -0700

> 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 :-(

Yuan