From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#13814: 24.3.50; Dynamic variables shadowing prevent defvar Date: Mon, 23 Aug 2021 03:21:26 +0200 Message-ID: <87y28tt0q1.fsf@gnus.org> References: <87hal0199m.fsf@orion.kollektiv-hamburg.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36567"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 13814@debbugs.gnu.org, Jorgen Schaefer To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Aug 23 03:22:24 2021 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 1mHyfP-0009GU-U4 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 23 Aug 2021 03:22:23 +0200 Original-Received: from localhost ([::1]:42922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHyfO-0000qj-TZ for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 22 Aug 2021 21:22:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHyf4-0000pS-Dz for bug-gnu-emacs@gnu.org; Sun, 22 Aug 2021 21:22:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56767) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHyf4-0008SG-2q for bug-gnu-emacs@gnu.org; Sun, 22 Aug 2021 21:22:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mHyf3-0006Wp-TY for bug-gnu-emacs@gnu.org; Sun, 22 Aug 2021 21:22:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 23 Aug 2021 01:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13814 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 13814-submit@debbugs.gnu.org id=B13814.162968170825061 (code B ref 13814); Mon, 23 Aug 2021 01:22:01 +0000 Original-Received: (at 13814) by debbugs.gnu.org; 23 Aug 2021 01:21:48 +0000 Original-Received: from localhost ([127.0.0.1]:40077 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mHyel-0006W5-Uc for submit@debbugs.gnu.org; Sun, 22 Aug 2021 21:21:48 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:38882) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mHyeg-0006Vl-RH for 13814@debbugs.gnu.org; Sun, 22 Aug 2021 21:21:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=2srqWqdkWyKLYil/urY/krfqdAHdsDMt1XcwRzkGJ4E=; b=AAQGZDW+s5u1ghrsf71CTWw/G0 k5KBi7F3Uv8yjK+nVKzttoGoEGKiXbm4sWumbTkPrAkM/D+dqLE1wRGrsuJ1t99Sz2RTI4D/xsS4g tho9yYFpnt3+LWlLmZPS76+tS8z04PuUzzFJY+4rLFgxUXVB4x58d7DFa1chhVQVrV2w=; Original-Received: from [84.212.220.105] (helo=elva) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mHyeV-0005WC-5U; Mon, 23 Aug 2021 03:21:31 +0200 In-Reply-To: (Stefan Monnier's message of "Mon, 25 Feb 2013 19:03:05 -0500") 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" Xref: news.gmane.io gmane.emacs.bugs:212456 Archived-At: Stefan Monnier writes: > Thanks for filing it, so we have a clear bug-number for this long > standing problem. If someone wants to take a crack at fixing it, > I think that we should add a `set-toplevel-default' which defvar and > defcustom could use, as for how to implement it, I you can take a look > at the check&warning in the C code of `defvar'. When running this from M-: now, I get the following backtrace: Debugger entered--Lisp error: (error "Defining as dynamic an already lexical var") (defvar bug-variable t "This variable is not defined when autoloaded.") eval-buffer(# nil "/tmp/bug-lib.el" nil t) ; Reading at buffer position 74 load-with-code-conversion("/tmp/bug-lib.el" "/tmp/bug-lib.el" nil t) (bug-variable-value) (let ((bug-variable nil)) (bug-variable-value)) eval((let ((bug-variable nil)) (bug-variable-value)) t) eval-expression((let ((bug-variable nil)) (bug-variable-value)) nil nil 127) funcall-interactively(eval-expression (let ((bug-variable nil)) (bug-variable-value)) nil nil 127) call-interactively(eval-expression nil nil) So this signals an error when doing the (let ((bug-variable nil)) (bug-variable-value)) from a lexical context. And... from a dynamic context, it seems like this works as it should now? That is, the defvar "punches through" the let binding and defines the variable properly. (Which I didn't know; last time I looked at this, it didn't work, but it's some years back.) Has this been fixed, or am I testing it wrong somehow? -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no