From: Eli Zaretskii <eliz@gnu.org>
To: Denis Zubarev <dvzubarev@yandex.ru>, Yuan Fu <casouri@gmail.com>
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: Thu, 28 Dec 2023 11:08:11 +0200 [thread overview]
Message-ID: <83zfxu7kzo.fsf@gnu.org> (raw)
In-Reply-To: <874jg90yt9.fsf@yandex.ru> (message from Denis Zubarev on Sat, 23 Dec 2023 17:37:54 +0300)
> From: Denis Zubarev <dvzubarev@yandex.ru>
> Date: Sat, 23 Dec 2023 17:37:54 +0300
>
>
> 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
Yuan, any comments?
next prev parent reply other threads:[~2023-12-28 9:08 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 [this message]
2023-12-30 3:54 ` Yuan Fu
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=83zfxu7kzo.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=67990@debbugs.gnu.org \
--cc=casouri@gmail.com \
--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.