From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu 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: Fri, 29 Dec 2023 19:54:27 -0800 Message-ID: <3BA064EC-36D3-4C9E-AA23-70034DE9A0CA@gmail.com> References: <874jg90yt9.fsf@yandex.ru> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18102"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 67990@debbugs.gnu.org To: Denis Zubarev Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 30 04:55:26 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 1rJQRZ-0004X8-II for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 30 Dec 2023 04:55:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rJQRD-0007lm-8Q; Fri, 29 Dec 2023 22:55:03 -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 1rJQRC-0007la-6M for bug-gnu-emacs@gnu.org; Fri, 29 Dec 2023 22:55:02 -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 1rJQRB-0001pR-LP for bug-gnu-emacs@gnu.org; Fri, 29 Dec 2023 22:55:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rJQRB-0000Hj-Kt for bug-gnu-emacs@gnu.org; Fri, 29 Dec 2023 22:55:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 30 Dec 2023 03:55:01 +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.17039084881070 (code B ref 67990); Sat, 30 Dec 2023 03:55:01 +0000 Original-Received: (at 67990) by debbugs.gnu.org; 30 Dec 2023 03:54:48 +0000 Original-Received: from localhost ([127.0.0.1]:42780 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rJQQy-0000HB-1Q for submit@debbugs.gnu.org; Fri, 29 Dec 2023 22:54:48 -0500 Original-Received: from mail-oi1-x230.google.com ([2607:f8b0:4864:20::230]:50667) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rJQQv-0000Gy-RS for 67990@debbugs.gnu.org; Fri, 29 Dec 2023 22:54:46 -0500 Original-Received: by mail-oi1-x230.google.com with SMTP id 5614622812f47-3bb53e20a43so6144883b6e.1 for <67990@debbugs.gnu.org>; Fri, 29 Dec 2023 19:54:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703908480; x=1704513280; darn=debbugs.gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=g1K8n2JlIkBzZVDF6g6onZrmT0WkWLuGPOxMLd02ANI=; b=hS0gfR1WhGlXUb3fW4ZmYJTWGV5PxdcELkaA9cNX9515t3YM2Sl51GFR3XiOW2ir3L mnnTIPE2q3VNqVEls4JX0Alb8tEuCFiWHtUsg5gnasVGn8TrV2NuVrzO/Fegc3QgFJGm triZvk8WsMH88/lMXyHXbw9YHliJHdtEdkfVb1GXjuIb31Rb38X6xF3q5BywJDSYNDEu Xa9jERj2T7XdCL+hU8TaIPEiefRM6b0BqQQ+lS03JwbNcCMSaJ1qr08EcKQIbrV0j3+3 qAEBIc8AmGncWC1BuX5zR6FTRtZA6cxbbQxJjXXyo4fjh6cOhp55PG85UPZsofpmiLx6 VtCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703908480; x=1704513280; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g1K8n2JlIkBzZVDF6g6onZrmT0WkWLuGPOxMLd02ANI=; b=Ae6JrGeGWmyi1B6Lrvr6aSvzJ9IVBK9HXQNwKymy7JosN1xMrWa99tGwR9Mx+kOP9N m4lToLfzvogsPzsL6m3DfFDwC14834Ov/xDHe8g25JLb1r84s29Q1KCzVjT2JGUmhrBQ 8W1r8g6xpcWRvsL4u8ulT46JQSDtABnQ0b1iyxbYDaSiAYFuqtXNG68QCHfcaBIefxv/ kjYUtFLDrFDdGNmsPbZgoGFwU4ond3PBiA7EzUfgkhwzj1FX7ehpWMtFYVfgqGBWNHcE G4J2l+aeiH1P0RZoZk2UztATug06RVrVSrballwLWVVcEtjQ2F8ETFlcpgNA25b6Rg4i kLCQ== X-Gm-Message-State: AOJu0YzZZ6HjKQ5M/NwsdrPeHoYZy4GGcv5szAGDLA7dIz70CU0Vppuv aKjOxyfpSs2zga9rMfItUtM= X-Google-Smtp-Source: AGHT+IE3BX/Ez4PHwYTU0QS+bcEA6DQera3Xj+Opburv7dURu0mtTeziCx64i2g25GFKujHZHwf9Cw== X-Received: by 2002:a05:6808:1a20:b0:3bb:f1ed:c8ce with SMTP id bk32-20020a0568081a2000b003bbf1edc8cemr646552oib.12.1703908479644; Fri, 29 Dec 2023 19:54:39 -0800 (PST) Original-Received: from smtpclient.apple (172-117-161-177.res.spectrum.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id x7-20020aa793a7000000b006d9aaee2f57sm11475302pff.102.2023.12.29.19.54.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Dec 2023 19:54:39 -0800 (PST) In-Reply-To: <874jg90yt9.fsf@yandex.ru> X-Mailer: Apple Mail (2.3731.700.6) 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:277052 Archived-At: > On Dec 23, 2023, at 6:37 AM, Denis Zubarev = wrote: >=20 >=20 > libtree-sitter is compiled from sources (latest version)=20 >=20 > 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 >=20 > 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)))) >=20 >=20 > 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] >=20 >=20 > Version from the playground has correctly assigned fields: > parenthesized_expression - condition:, block is labeled as > consequence:, the second comparison_operator - right: >=20 > 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. >=20 > 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 >=20 > 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 >=20 >=20 > * 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=