Subject: Re: bug#78065: 31.0.50; treesit-simple-indent-rules: nth-sibling anchor preset doesn't work properly

From: Yuan Fu <[email-masked]>
Date: Tue, 6 May 2025 21:30:49 -0700

> On Apr 25, 2025, at 12:04 PM, Roman Rudakov <[email-masked]> wrote:
> 
> 
> The bug itself is actually in 'treesit--simple-indent-eval' function.
> 
> Steps to reproduce:
> 
> Eval the following expression:
> (treesit--simple-indent-eval '(nth-sibling 1 t))
> 
> Expected result: anchor lambda is returned.
> 
> Actual result:
> 
> Debugger entered--Lisp error: (treesit-indent-error "Couldn't find the preset corresponding to expression" t)
> 
> The function 'treesit--simple-indent-eval' is called recursively for every element in the expression, at some point it's called for 't', which matches '(symbolp exp)' predicate and is not null, which causes the error.

Hey Roman, thank you for the report, and sorry for taking so long to reply.

I initially added a branch cases to allow exp to be t, but then I realized that there’s no point inhibiting exp from being an arbitrary symbol or keyword, since user can define indent presets that takes a symbol or keyword as argument. So I went a step further and removed the check.

I pushed the fix to emacs-30.

Yuan