From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: scratch/accurate-warning-pos: next steps. Date: Tue, 11 Dec 2018 14:21:33 -0500 Message-ID: References: <20181210180033.GC4188@ACM> <831s6p2qq1.fsf@gnu.org> <20181210182830.GD4188@ACM> <83zhtd1b0j.fsf@gnu.org> <20181210193557.GE4188@ACM> <83y38x1706.fsf@gnu.org> <20181210210310.GF4188@ACM> <83lg4w1s77.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1544556037 20291 195.159.176.226 (11 Dec 2018 19:20:37 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 11 Dec 2018 19:20:37 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 11 20:20:33 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gWna2-00058J-SU for ged-emacs-devel@m.gmane.org; Tue, 11 Dec 2018 20:20:31 +0100 Original-Received: from localhost ([::1]:41106 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWnc7-0003Wb-Cm for ged-emacs-devel@m.gmane.org; Tue, 11 Dec 2018 14:22:41 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42262) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWnbI-00037Z-5P for emacs-devel@gnu.org; Tue, 11 Dec 2018 14:21:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gWnbE-0001C8-Pz for emacs-devel@gnu.org; Tue, 11 Dec 2018 14:21:48 -0500 Original-Received: from [195.159.176.226] (port=38181 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gWnbE-0001Bd-Fc for emacs-devel@gnu.org; Tue, 11 Dec 2018 14:21:44 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1gWnZ3-00040A-L5 for emacs-devel@gnu.org; Tue, 11 Dec 2018 20:19:29 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 31 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:Lpb2zhJPkwFW8gbR0Spq7dMu1os= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:231757 Archived-At: >> I'm not sure how this special-purpose code would work. Say we find an >> error or warning involving symbol foo as the car of some form, I can't >> see any way of determining its source position that doesn't involve going >> back to the position of the beginning of the form, and slogging through >> the form, somehow. > Yes, I was proposing something like that. Why is that a problem? IIUC what you're suggesting here is to add a heuristic which takes an arbitrary chunk of code (can be a single symbol but not necessarily), an approximate source location, and then tries to compute a better source location from it. I think making this 100% reliable (either in the sense of "return the *right* location" or just "return a location that's sometimes/often better and never worse") is somewhere between very hard and impossible. But maybe a few well chosen heuristics could indeed give a significant improvement (i.e. return a location that's sometimes/often better and rarely worse). To help the heuristic, we could pass it some indication of the error (e.g. so it knows whether the symbol (or chunk of code) we're looking for is expected to be in the position of a normal expression, a let-binding, a var definition, a function definition, a function call, ...). Oh wait: I think if we return a range rather than a single position, we could make it reliable in the sense that the actual position is within the range (but sometimes the range will degenerate to cover a whole top-level definition). Stefan