[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#67990: 30.0.50; tree-sitter: treesit-node-field-name-for-child seems
From: |
Eli Zaretskii |
Subject: |
bug#67990: 30.0.50; tree-sitter: treesit-node-field-name-for-child seems to be broken after recent changes |
Date: |
Sat, 30 Dec 2023 09:12:56 +0200 |
> Cc: 67990@debbugs.gnu.org
> From: Yuan Fu <casouri@gmail.com>
> Date: Fri, 29 Dec 2023 19:54:27 -0800
>
>
>
> > 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.
Thanks, I'm therefore closing this bug.