From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mickey Petersen Newsgroups: gmane.emacs.bugs Subject: bug#61235: 30.0.50; tree-sit: `treesit-node-check' lacks a way to tell if a node belongs to a deleted parser Date: Mon, 06 Feb 2023 13:19:57 +0000 Organization: Mastering Emacs Message-ID: <87k00uexdt.fsf@masteringemacs.org> References: <83edr3q8ez.fsf@gnu.org> <87o7q7dl4o.fsf@masteringemacs.org> <83a61rq6ck.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26733"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e @VERSION@; emacs 30.0.50 Cc: casouri@gmail.com, 61235@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 06 14:29:56 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 1pP1ZD-0006iE-2l for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 06 Feb 2023 14:29:55 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pP1YQ-0004IS-Eu; Mon, 06 Feb 2023 08:29:06 -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 1pP1YO-0004ID-Jz for bug-gnu-emacs@gnu.org; Mon, 06 Feb 2023 08:29:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pP1YM-0003Qq-TT for bug-gnu-emacs@gnu.org; Mon, 06 Feb 2023 08:29:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pP1YM-0007dn-Cq for bug-gnu-emacs@gnu.org; Mon, 06 Feb 2023 08:29:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mickey Petersen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 06 Feb 2023 13:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61235 X-GNU-PR-Package: emacs Original-Received: via spool by 61235-submit@debbugs.gnu.org id=B61235.167569012529342 (code B ref 61235); Mon, 06 Feb 2023 13:29:02 +0000 Original-Received: (at 61235) by debbugs.gnu.org; 6 Feb 2023 13:28:45 +0000 Original-Received: from localhost ([127.0.0.1]:47597 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pP1Y5-0007dB-8C for submit@debbugs.gnu.org; Mon, 06 Feb 2023 08:28:45 -0500 Original-Received: from mail-he1eur04on2112.outbound.protection.outlook.com ([40.107.7.112]:26689 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pP1Y3-0007cw-6w for 61235@debbugs.gnu.org; Mon, 06 Feb 2023 08:28:43 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vg0k7T28pC8Aj1J3vfT9URYHcbPOI0vz8PBO7m/xQhhiwO3kQf23yX+9G2APLYn+GGk+AuX7UW84z1qS8KYamm2V/gfHJ3XK6gnh+InkWBhazeu+RvQMt65XYIIByQLAQYQjTXNKpGa/+8x21GH+iG/JiaLIqJCH/FdcFVYtqvyIhqCJi7KMjcvu3hqDzrBQKsKd0IhUKyQRZTvqB7YHLDn51OnMBIGPiRmUV38MYlgIgStW86atQLuqYThTS1S9PUexsopYCdu9QTX/gx+ip9kkeAyUCBnoQHLY0PiNkDrgzA8ab+rDNp4NyUuDKh8kBejaVqfu60O+OOieshuHIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7JvPdzB4uGD4b2O0pEtU02RrsRihS3sm+Hfr3al9jDs=; b=JgI5zRyV99Gz2mMYg0gk6Vcv5S8vasEyg+rfQLYkmajbUaVbazRSil9L6We9jAloo4J2ZHXJZi9EF+i8imwNzyQ0wNTIn2OXQFd6y64vphJoQ+nhu4v+VbuqpXbcFFE3Tj2nmph4hl6tPSlilEr0tmCQ1/unupqLL76rGus2Krh6o2RdnBiYl1qCTH+rJfWOivo7ym6jpz5ptcbLiJqiaMVR5kPEW4lfE7R8e78n3CUmyaZkiCPeUUWHa47PsOAeNX0DggAiP3vnJv59zDKkSVoW5nZrwmYRb4x7ATByiCJPM0hqbMVKCN/NU40fGvYUESPTWe5EQqSFKb84Ms+fCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 178.79.136.144) smtp.rcpttodomain=debbugs.gnu.org smtp.mailfrom=masteringemacs.org; dmarc=pass (p=none sp=none pct=100) action=none header.from=masteringemacs.org; dkim=pass (signature was verified) header.d=masteringemacs.org; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semantical.onmicrosoft.com; s=selector1-semantical-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7JvPdzB4uGD4b2O0pEtU02RrsRihS3sm+Hfr3al9jDs=; b=OaCwzBkmKw3nKP0swpG/ET1D0cj+1mLppnRvuQvbk/JZDA68tR4VBGV2eVV1AtT8WwdOt3xWqXdmZfzvW/N7DrlcqIo/hWoGq4A6+QQqLnIOFYhSFjNCH1hljX8UIeaalNgIgwjQFtd5zY3E3MK7k84djDewAm1/xespw7rmkBY= Original-Received: from CWLP123CA0223.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:19f::6) by LO2P265MB4990.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:22d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Mon, 6 Feb 2023 13:28:34 +0000 Original-Received: from CWLGBR01FT007.eop-gbr01.prod.protection.outlook.com (2603:10a6:400:19f:cafe::88) by CWLP123CA0223.outlook.office365.com (2603:10a6:400:19f::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34 via Frontend Transport; Mon, 6 Feb 2023 13:28:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 178.79.136.144) smtp.mailfrom=masteringemacs.org; dkim=pass (signature was verified) header.d=masteringemacs.org;dmarc=pass action=none header.from=masteringemacs.org; Received-SPF: Pass (protection.outlook.com: domain of masteringemacs.org designates 178.79.136.144 as permitted sender) receiver=protection.outlook.com; client-ip=178.79.136.144; helo=semantical.co.uk; pr=C Original-Received: from semantical.co.uk (178.79.136.144) by CWLGBR01FT007.mail.protection.outlook.com (10.152.40.96) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32 via Frontend Transport; Mon, 6 Feb 2023 13:28:33 +0000 Original-Received: by semantical.co.uk (Postfix, from userid 5001) id 5A462114002; Mon, 6 Feb 2023 13:28:33 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=masteringemacs.org; s=masteringemacs.org; t=1675690113; bh=3bamt0W741r57uT69W6etCfJVC3+hCzH+TL7uYq3V8w=; h=References:From:To:Cc:Subject:Date:In-reply-to:From; b=JqYYAljQ/FdMkxpr0mHgM3Ol047XMk6e3z8Vpbgxw+bCj3kkRB5kPDcREx3lWGFTu G4gzSaFrPAZPFoEPfDXhHWcXCsCaAz+pQhLffcx+37HJw2Nf1aEP9K48lXKKjaCn1N c1ZTBNos91Y1Kp8zrFm69a8yN1184QGaUE6YRfoc= In-reply-to: <83a61rq6ck.fsf@gnu.org> X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CWLGBR01FT007:EE_|LO2P265MB4990:EE_ X-MS-Office365-Filtering-Correlation-Id: e6d31c43-2e85-48a2-5167-08db08460b83 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G0U+2GD/l29TGJu2922lAtLM62g7qEpRXLbMiErlOcaG7e499vm6dcvSUNJe2AsM6IbvQciL+tmXzNuJnWtxZrqdX1D1QYQfa10zde0e7kr+jzO6N3qmRJuH04Rx+jC5MFNOyHpa60NS0jTi1SyrxWmH4n5Sh+vA+b8h+rT8z4z5oX0Dfj0zUOY2NazXgRZiuEscDIW6fol2EEMcQdEEnSxo5coZ8e83twftON1xvSwOdYFiymEOPd9zQlHC3xVJtTExM9i7WwGe3pwatWHnLUo/8hdyoLGve12o7vdXJ3Pn+zHFTqA6V15I2rpCPudkx1gXZ/osIPq3sdY6ETjDtW23/Z/b/PUxZKe+X96Dbmg5tJGTb0izeyUAE2pP5mYX6dN+FMmHK28uYW5FHtTU0Kawo1I8JAOAYP/f39PXXcKDUIVl0v49y/T9zOmqS0qtuRVJ2W6qDE8eWoaL6J95PPGggVLeaHU/b+QtPDNDiJJymM4x3zcf6WZh+CFZo1v/MQEBLIGIZGSnpkbaaQVJ+xSnzygf9SFqiu6Yzj79A/BcNUd+8fYtGhFMxEl0+hvkdVGXGEDdklyiYmieHhtPWGQFVtcj5ft6ygGGReBjI/8L4mXwajlj9IQQ16ozp3WK8a0Mij+gL7H6FxjSSObcEmgPZLA69QbG6Nf07zwfnokNm8iMyB1EsKeqfQI9sAB9VsCuduFJ0YykCPuF0JANeCGCy6QkfovYtCn8n1gKtwNXNEV38oL8HHkYB6xCH X64jk8cC79049EPO3OmlOaakr1GdInX9ABA7n4/8hpsYc+HoR57m/KfT2CJdDcuFxin X-Forefront-Antispam-Report: CIP:178.79.136.144; CTRY:GB; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:semantical.co.uk; PTR:semantical.co.uk; CAT:NONE; SFS:(13230025)(346002)(39830400003)(396003)(136003)(376002)(451199018)(46966006)(36840700001)(36756003)(36916002)(478600001)(316002)(2906002)(42186006)(7636003)(86362001)(40480700001)(356005)(82310400005)(7596003)(47076005)(336012)(2616005)(66899018)(70586007)(6666004)(83380400001)(70206006)(8676002)(4326008)(8936002)(6862004)(41300700001)(5660300002)(6266002)(186003)(26005)(36860700001)(38230200001)(81973001)(43043002)(79816003)(14776008); DIR:OUT; SFP:1102; X-OriginatorOrg: masteringemacs.org X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2023 13:28:33.6320 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e6d31c43-2e85-48a2-5167-08db08460b83 X-MS-Exchange-CrossTenant-Id: a4e27e3d-bab0-45e8-8942-e64cf9fbd34f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a4e27e3d-bab0-45e8-8942-e64cf9fbd34f; Ip=[178.79.136.144]; Helo=[semantical.co.uk] X-MS-Exchange-CrossTenant-AuthSource: CWLGBR01FT007.eop-gbr01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LO2P265MB4990 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:254958 Archived-At: Eli Zaretskii writes: >> From: Mickey Petersen >> Cc: Yuan Fu , 61235@debbugs.gnu.org >> Date: Mon, 06 Feb 2023 12:35:20 +0000 >> >> > I'm not sure I understand the need. AFAIU, a parser is deleted only >> > if we call treesit-parser-delete; are we saying that a Lisp program >> > doesn't know that it deleted a parser? What exactly is the practical >> > situation where this problem happens, and why? >> > >> > Frankly, I don't think we should at this stage add APIs without a very >> > good reason. We should instead collect experience, both from users >> > and from Lisp programs, and analyze them before deciding whether more >> > APIs are necessary. >> > >> >> Because node references are retained even after a parser is deleted. >> >> Retrieving a node; somehow deleting the parser (maybe you closed the >> buffer, or you were doing some off-hand parsing); and then doing >> _anything_ with the aforementioned node yields an error for which >> there is no way to test for. >> >> This is particularly the case when you mix and match parsers in the >> same buffer. > > I'm asking why the Lisp program cannot track the parsers its uses and > deletes, and instead expects the core to do the janitor's job for it. Because I have a proxy-like object of a real node because they're invalidated if a buffer is edited, even if the parcel of code I hold a node reference to is untouched. That's just how tree-sitter works, so I deal with it like this. That part works fine for I can of course use `treesit-node-check' to determine if it's outdated and thus needs refreshing (or not.) The problems begin when the parser is also, for one reason or another, destroyed. Now I can no longer determine if it is safe to use the existing (real) node reference. Any attempt to use a "dangling" node reference that points to a dead parser throws a nasty error. Thus, the extension to `treesit-node-check' that can tell if a node belongs to a dead parser --- something that tree-sitter and the C core clearly knows about internally.