all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: Denis Zubarev <dvzubarev@yandex.ru>
Cc: 67990@debbugs.gnu.org
Subject: bug#67990: 30.0.50; tree-sitter: treesit-node-field-name-for-child seems to be broken after recent changes
Date: Fri, 29 Dec 2023 19:54:27 -0800	[thread overview]
Message-ID: <3BA064EC-36D3-4C9E-AA23-70034DE9A0CA@gmail.com> (raw)
In-Reply-To: <874jg90yt9.fsf@yandex.ru>



> On Dec 23, 2023, at 6:37 AM, Denis Zubarev <dvzubarev@yandex.ru> wrote:
> 
> 
> libtree-sitter is compiled from sources (latest version) 
> 
> Steps to reproduce:
> 1. emacs -Q
> 2. M-x find-file /tmp/t.py
> 3. Paste there
> if (v is not None and #comment
>    v > 0):
>   pass
> 4. M-x python-ts-mode
> 5. M-x treesit-explore-mode
>    python
> 
> Parse tree:
> (module
> (if_statement if
>  (parenthesized_expression (
>   (boolean_operator
>    left: (comparison_operator (identifier) operators: is not operators: is not operators: (none))
>    operator: and operator: (comment)
>    operator: (comparison_operator (identifier) operators: > operators: (integer)))
>   ))
>  condition: :
>  condition:
>   (block
>    (pass_statement pass))))
> 
> 
> Parse tree from the playground:
> module [0, 0] - [4, 0]
>  if_statement [0, 0] - [2, 7]
>    condition: parenthesized_expression [0, 3] - [1, 10]
>      boolean_operator [0, 4] - [1, 9]
>        left: comparison_operator [0, 4] - [0, 17]
>          identifier [0, 4] - [0, 5]
>          none [0, 13] - [0, 17]
>        comment [0, 22] - [0, 30]
>        right: comparison_operator [1, 4] - [1, 9]
>          identifier [1, 4] - [1, 5]
>          integer [1, 8] - [1, 9]
>    consequence: block [2, 3] - [2, 7]
>      pass_statement [2, 3] - [2, 7]
> 
> 
> Version from the playground has correctly assigned fields:
> parenthesized_expression - condition:, block is labeled as
> consequence:, the second comparison_operator - right:
> 
> I noticed this regression after 9874561f39e62c1c9fada6c2e013f93d9ea65729.
> Quote from this commit "So turns out ts_node_field_name_for_child takes a named node index,"
> It seems that was a bug in the libtree-sitter and they fixed it in
> https://github.com/tree-sitter/tree-sitter/pull/2104
> Unfortunately, there is no release with this fix yet.
> 
> I have tested various combinations of libtree-sitter and fix from 9874561f39:
> With commit 9874561f39
> libtree-sitter v0.20.8 - condition: and consequence: fields are wrongly assigned
> libtree-sitter version with the fix* - most fields are broken
> 
> When reverting commit 9874561f39
> libtree-sitter v0.20.8 - only right: field is wrong (points to the comment node)
> libtree-sitter version with the fix* - ok
> 
> 
> * tree-sitter version with the fix:
> git clone https://github.com/tree-sitter/tree-sitter.git
> git checkout 6d1904c221d15d2fcbe0b590ff0a3f96c692429f
> It is needed to recompile grammar after changing the libtree-sitter version.

Thank you very much! So it seems that we should revert that commit, and point to libtree-sitter if people come to us reporting errors. I reverted that commit on emacs-29.

Yuan




  parent reply	other threads:[~2023-12-30  3:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-23 14:37 bug#67990: 30.0.50; tree-sitter: treesit-node-field-name-for-child seems to be broken after recent changes Denis Zubarev
2023-12-28  9:08 ` Eli Zaretskii
2023-12-30  3:54 ` Yuan Fu [this message]
2023-12-30  7:12   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3BA064EC-36D3-4C9E-AA23-70034DE9A0CA@gmail.com \
    --to=casouri@gmail.com \
    --cc=67990@debbugs.gnu.org \
    --cc=dvzubarev@yandex.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.