From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs 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 Message-ID: <83zfxs40zr.fsf@gnu.org> References: <874jg90yt9.fsf@yandex.ru> <3BA064EC-36D3-4C9E-AA23-70034DE9A0CA@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38755"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 67990-done@debbugs.gnu.org, dvzubarev@yandex.ru To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 30 08:14:27 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rJTYB-0009sA-8W for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 30 Dec 2023 08:14:27 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rJTXr-0005E1-It; Sat, 30 Dec 2023 02:14:07 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rJTXn-0005CI-KK for bug-gnu-emacs@gnu.org; Sat, 30 Dec 2023 02:14:04 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rJTXm-0001w7-GH for bug-gnu-emacs@gnu.org; Sat, 30 Dec 2023 02:14:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rJTXm-0005tq-I4 for bug-gnu-emacs@gnu.org; Sat, 30 Dec 2023 02:14:02 -0500 Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Sat, 30 Dec 2023 07:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 67990 X-GNU-PR-Package: emacs Mail-Followup-To: 67990@debbugs.gnu.org, eliz@gnu.org, dvzubarev@yandex.ru Original-Received: via spool by 67990-done@debbugs.gnu.org id=D67990.170392040222600 (code D ref 67990); Sat, 30 Dec 2023 07:14:02 +0000 Original-Received: (at 67990-done) by debbugs.gnu.org; 30 Dec 2023 07:13:22 +0000 Original-Received: from localhost ([127.0.0.1]:42913 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rJTX7-0005sR-Hc for submit@debbugs.gnu.org; Sat, 30 Dec 2023 02:13:22 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57472) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rJTX6-0005sF-0q for 67990-done@debbugs.gnu.org; Sat, 30 Dec 2023 02:13:21 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rJTWs-0001Jv-9l; Sat, 30 Dec 2023 02:13:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=/TaKJMSffi+krejNF0e362Ir7uKgLIpCnVbaMhxcZfY=; b=A5XYZS5dCv5O xtLQpKQtcC3dnR2/ZhW+TmYcBFcTi2GW6h+vIttJLbzbJ2KqebSgFfwvkjdybrKO+YZb7GI+Rknmw XBkkQHJ9zPyRkKLhfmoI+8oq0eBmbXMMafRVxfe4AiNMhlJbd94p3sfQKjVBcwFfMaZ5OlZtuJJZi Py1YC3nOhi5VMU63hVZ9ZkbZKC1Pi1subTzmnPFPj+gnW14HoJp2sIspJsCFKycSvrpPtfcUA11YM DQa23Y7Hwni3UP47g1w14kS6vx1SO8LmLISPdDp0gjZl9DjQp0k6lZSfnoF7KoX+gcnO33RCP7ZGR aTVm8wk0fF7elzSGITey+g==; In-Reply-To: <3BA064EC-36D3-4C9E-AA23-70034DE9A0CA@gmail.com> (message from Yuan Fu on Fri, 29 Dec 2023 19:54:27 -0800) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:277059 Archived-At: > Cc: 67990@debbugs.gnu.org > From: Yuan Fu > Date: Fri, 29 Dec 2023 19:54:27 -0800 > > > > > On Dec 23, 2023, at 6:37 AM, Denis Zubarev 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.