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: Thu, 28 Dec 2023 11:08:11 +0200 Message-ID: <83zfxu7kzo.fsf@gnu.org> References: <874jg90yt9.fsf@yandex.ru> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19008"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 67990@debbugs.gnu.org To: Denis Zubarev , Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 28 10:09:16 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 1rImOB-0004nR-W9 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 28 Dec 2023 10:09:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rImO0-0003a4-Mn; Thu, 28 Dec 2023 04:09:04 -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 1rImNz-0003Zo-EN for bug-gnu-emacs@gnu.org; Thu, 28 Dec 2023 04:09:03 -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 1rImNz-0003nC-5x for bug-gnu-emacs@gnu.org; Thu, 28 Dec 2023 04:09:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rImNy-00086u-9b for bug-gnu-emacs@gnu.org; Thu, 28 Dec 2023 04:09:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 28 Dec 2023 09:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67990 X-GNU-PR-Package: emacs Original-Received: via spool by 67990-submit@debbugs.gnu.org id=B67990.170375451231135 (code B ref 67990); Thu, 28 Dec 2023 09:09:02 +0000 Original-Received: (at 67990) by debbugs.gnu.org; 28 Dec 2023 09:08:32 +0000 Original-Received: from localhost ([127.0.0.1]:38436 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rImNU-000867-1z for submit@debbugs.gnu.org; Thu, 28 Dec 2023 04:08:32 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53070) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rImNS-00085v-24 for 67990@debbugs.gnu.org; Thu, 28 Dec 2023 04:08:30 -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 1rImNN-0003i0-9S; Thu, 28 Dec 2023 04:08:25 -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=XZqHCOlez64vM/25ySLbisVKLQA5b4OPaacl2je6Jqo=; b=r6dwLSfD+J2o w3+U6DBtA725liZUoLrXCI6TfgKHN2tNnf9jlbz7V57+GcK1m/OqqsSk2tYwEKm0LL20cILnHRx4A jZgyE+URXr2dneBFm9v+2Eypatwx1vBj2twvdVanXnOo/EMxVmSM9R+TkarKU0FMYf7wJtvB6sBx3 v5HmWqYFX2YXTLcNgf9hRY3uyrT8OdnpO9Cz9vxEsaAgs7T6x5uVszw42kFG7lbMbhphCga6JmjrS Csd4JNoypQknj/VhSwl40ZHtwvLcnDNIzp5wmBzmei0MeIpy2kxwUU1RLah5aSgJkDnIGPNL/lsG7 ygQFgfTEoMe5OR1awxSgEg==; In-Reply-To: <874jg90yt9.fsf@yandex.ru> (message from Denis Zubarev on Sat, 23 Dec 2023 17:37:54 +0300) 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:276965 Archived-At: > From: Denis Zubarev > 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?