From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#67483: Wrong warning position given by the byte compiler for a malformed function Date: Thu, 21 Dec 2023 13:22:17 +0100 Message-ID: <522B6349-614D-48AD-963D-76CF59A30497@gmail.com> References: <59773797-CC64-4352-9528-4E7593DD3C1F@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_2B565CCF-B729-469E-BBE8-767A85FCC4DB" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9051"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier , 67483@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 21 13:23:18 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 1rGI58-0002AJ-K2 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 21 Dec 2023 13:23:18 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGI4q-0001k8-8s; Thu, 21 Dec 2023 07:23:00 -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 1rGI4o-0001jm-UL for bug-gnu-emacs@gnu.org; Thu, 21 Dec 2023 07:22:59 -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 1rGI4o-0002Rm-KB for bug-gnu-emacs@gnu.org; Thu, 21 Dec 2023 07:22:58 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rGI4s-0005LA-9Q for bug-gnu-emacs@gnu.org; Thu, 21 Dec 2023 07:23:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 21 Dec 2023 12:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67483 X-GNU-PR-Package: emacs Original-Received: via spool by 67483-submit@debbugs.gnu.org id=B67483.170316135520495 (code B ref 67483); Thu, 21 Dec 2023 12:23:02 +0000 Original-Received: (at 67483) by debbugs.gnu.org; 21 Dec 2023 12:22:35 +0000 Original-Received: from localhost ([127.0.0.1]:42591 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rGI4Q-0005KV-Su for submit@debbugs.gnu.org; Thu, 21 Dec 2023 07:22:35 -0500 Original-Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]:50655) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rGI4K-0005KD-Ty for 67483@debbugs.gnu.org; Thu, 21 Dec 2023 07:22:33 -0500 Original-Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-50e281b149aso899474e87.1 for <67483@debbugs.gnu.org>; Thu, 21 Dec 2023 04:22:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703161339; x=1703766139; darn=debbugs.gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:sender:from:to:cc:subject:date:message-id:reply-to; bh=6sbZISITKjHUoLPotSrNniiZG4o5OBW7tAcCFDRLlGg=; b=B+yXUC8xMlU6RQ1JkhvZSP8gdkqFuKUpzdD8qOEyUay22q241uKDyoTbbmYts2vcrF oGDtSOjghBx+MKr9EHzszg+Y01g0WjK6OfV7uECuIRS///JImfyHEGe8PsKq8/fa5ZBA aeV8FmasdzoEjqjeDzbDDtsUxBAzqSk47af3YTHpw6SOaVdn+EIQkFMwD3EMpFTtivee vHi8iYMF7+E0jIOD+FdPO7g+Xzdwjx6NFrXQSSyRVmLrY+JUP3tXgsLEOjX5cNd4Rv6o NnVQnm9fsFvzMvET2yZSL2LMcvE1MfxfDl6zo1HmGAzirZqsEPap76V83SdW7Nuw71Kq 6ubQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703161339; x=1703766139; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6sbZISITKjHUoLPotSrNniiZG4o5OBW7tAcCFDRLlGg=; b=CZa3dmsOZGHDWvcz4I9vwCmT9mpHTfVIGcV5xFkgdR1szMvzwICPkeIs98SWgjOx0M ivT3eC8gyDmx2zorq9zNZGeFEBiVn9KGNdl+jCawBDYsFA81r6gdpSXAjQ8rfscqx8Nr cynlION+iNv3eS2KgZO+Q8v6TP2T3yjtCp4aY0i86HpGL1sp0yyYHh/4SMwwn0ZYEwka UI6lghuaEluAEoHJntvfMChxcPSPEJHFuva4wOnGFnrdjmGa4ioiJ3/XUZ9lQxAPoAZ5 e76Vq3v5ckiCG4/g2OJL63SjFO+Oer+atpzfNijSkj2iiwgdNZ1e/3LaKzYbjzgZHe6Z mzoA== X-Gm-Message-State: AOJu0Yy5TTyx9mmvcuzJDcAxOBgTVFn39vaK/XUwZMqiSJEmrQ9MDewr 9H+EPObdDZEtrHekcAYkHlI= X-Google-Smtp-Source: AGHT+IGRchBPfxcYIybvfk7pp/5iw/GjFzAKOjQDLXuCCPv64JBpGNERA+CA4fXLbIDc51uLBXTZXQ== X-Received: by 2002:ac2:58f1:0:b0:50e:2800:d87c with SMTP id v17-20020ac258f1000000b0050e2800d87cmr3931616lfo.98.1703161338519; Thu, 21 Dec 2023 04:22:18 -0800 (PST) Original-Received: from smtpclient.apple (c80-217-1-132.bredband.tele2.se. [80.217.1.132]) by smtp.gmail.com with ESMTPSA id i12-20020a056512006c00b0050cf2182f13sm254341lfo.187.2023.12.21.04.22.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Dec 2023 04:22:18 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3654.120.0.1.15) 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:276625 Archived-At: --Apple-Mail=_2B565CCF-B729-469E-BBE8-767A85FCC4DB Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 4 dec. 2023 kl. 19.19 skrev Alan Mackenzie : > You've undone the bug fix, and the bug is there again. Oops. An honest mistake, very sorry about that. On the other hand, these blunders often turn out to be beneficial in the = end because they force us to take a better look at the problem. I ended up maintaining `byte-compile-form-stack` in `cconv-convert` = which isn't free but a lot better than doing it in the optimiser. We = emit a fair amount of warnings in cconv so this should be useful for = other reasons as well. The warning was also reverted from delayed to immediate, which makes = sense in this case (since it's essentially a syntax error) and in fact = it wouldn't work otherwise because delayed warnings implicitly use the = byte-compile-form-stack we have when traversing the post-optimisation = tree in codegen. I'm inclined to do something about this last problem for good measure = (see attached patch). Most of the time the byte-compile-form-stack = doesn't matter much because the warning argument contains a symbol with = position, but when it does, the stack state in codegen when the warning = is emitted is likely to be less useful than when the warning was = registered in the front-end. Haven't made up my mind about this yet. > We do indeed, but here binding the variable simply doesn't work. = Parts > of the compiler, when they encounter errors, signal an error which = gets > caught by a condition-case somewhere. Yes, so I noticed. This is rubbish of course; we should do something = about it. We have some options. Meanwhile I made a macro to encapsulate the ugly push-pop logic in one = place. --Apple-Mail=_2B565CCF-B729-469E-BBE8-767A85FCC4DB Content-Disposition: attachment; filename=0001-Capture-byte-compile-form-stack-in-delayed-warnings-.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Capture-byte-compile-form-stack-in-delayed-warnings-.patch" Content-Transfer-Encoding: quoted-printable =46rom=200a4222090ee3b6690b3097a06dacd23546c7350b=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Wed,=2020=20Dec=202023=2011:11:56=20+0100=0A= Subject:=20[PATCH]=20Capture=20byte-compile-form-stack=20in=20delayed=20= warnings=0A=20(bug#67483)=0A=0A*=20lisp/emacs-lisp/macroexp.el=20= (macroexp--warn-wrap):=0AWhen=20recording=20a=20delayed=20warning,=20= capture=20the=20current=20value=20of=0A`byte-compile-form-stack`=20= because=20it=20is=20more=20likely=20to=20contain=20a=0Arelevant=20source=20= location=20than=20whatever=20we=20are=20traversing=20in=20codegen.=0A---=0A= =20lisp/emacs-lisp/macroexp.el=20|=2014=20++++++++------=0A=201=20file=20= changed,=208=20insertions(+),=206=20deletions(-)=0A=0Adiff=20--git=20= a/lisp/emacs-lisp/macroexp.el=20b/lisp/emacs-lisp/macroexp.el=0Aindex=20= 2a646be9725..8cf6ad7256d=20100644=0A---=20a/lisp/emacs-lisp/macroexp.el=0A= +++=20b/lisp/emacs-lisp/macroexp.el=0A@@=20-168,12=20+168,14=20@@=20= macroexp-file-name=0A=20(defvar=20macroexp--warned=20(make-hash-table=20= :test=20#'equal=20:weakness=20'key))=0A=20=0A=20(defun=20= macroexp--warn-wrap=20(arg=20msg=20form=20category)=0A-=20=20(let=20= ((when-compiled=0A-=09=20(lambda=20()=0A-=20=20=20=20=20=20=20=20=20=20=20= (when=20(if=20(consp=20category)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20(apply=20#'byte-compile-warning-enabled-p=20= category)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (byte-compile-warning-enabled-p=20category))=0A-=20=20=20=20=20=20=20=20=20= =20=20=20=20(byte-compile-warn-x=20arg=20"%s"=20msg)))))=0A+=20=20(let*=20= ((stack=20byte-compile-form-stack)=0A+=20=20=20=20=20=20=20=20=20= (when-compiled=0A+=09=20=20(lambda=20()=0A+=20=20=20=20=20=20=20=20=20=20= =20=20(when=20(if=20(consp=20category)=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20(apply=20= #'byte-compile-warning-enabled-p=20category)=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20(byte-compile-warning-enabled-p=20= category))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20(let=20= ((byte-compile-form-stack=20stack))=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(byte-compile-warn-x=20arg=20"%s"=20msg))))))=0A=20=20=20=20=20= `(progn=0A=20=20=20=20=20=20=20=20(macroexp--funcall-if-compiled=20= ',when-compiled)=0A=20=20=20=20=20=20=20=20,form)))=0A--=20=0A2.32.0=20= (Apple=20Git-132)=0A=0A= --Apple-Mail=_2B565CCF-B729-469E-BBE8-767A85FCC4DB--