unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Joseph Mingrone <jrm@ftfl.ca>
To: 46912@debbugs.gnu.org
Cc: Vitalie Spinu <spinuvit@gmail.com>, emacs-devel@gnu.org
Subject: bug#46912: 28.0.50; Byte compiled defvar with lexical binding throws (void-variable foo)
Date: Thu, 04 Mar 2021 14:03:45 -0400	[thread overview]
Message-ID: <868s72re2m.fsf@phe.ftfl.ca> (raw)
In-Reply-To: <CAAQMm-85X7hMaYoce-Hw84AL957pQPhi1zZMme2xLrE2CEqmag@mail.gmail.com> (Vitalie Spinu's message of "Thu, 4 Mar 2021 01:14:50 +0100")

On Thu, 2021-03-04 at 01:14, Vitalie Spinu <spinuvit@gmail.com> wrote:

> Hello,

> Compiling the following file:

>     ;;; -*- lexical-binding: t -*-

>     (let ((foo t))
>       (defvar tmp-bar (if foo 0 1 -1)))

> gives:

>     tmp.el:4:23: Warning: reference to free variable ‘foo’


> When loading the .elc file the error

>     Debugger entered--Lisp error: (void-variable foo)
>       byte-code("\301\10\203\11\0\302\202\n\0\303!\207" [foo (lambda
> (def-tmp-var) (defvar tmp-bar def-tmp-var)) 0 -1] 2)
>       load(".../tmp.elc" nil nil t)


> No problems with emacs-27 branch.


>   Vitalie



> In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
> 3.22.30, cairo version 1.15.10)
>  of 2021-03-03 built on NB277
> Repository revision: a350ae058caedcb7be7d332564817954e3624e60
> Repository branch: HEAD
> Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
> System Description: Ubuntu 18.04.5 LTS

Hi,

With

     ;;; -*- lexical-binding: t -*-

     (let ((foo t))
       (defvar tmp-bar foo))

the same warning is reported when compiling, but when loading the .elc
file, the debugger isn't started.  Just

     load: Symbol’s value as variable is void: foo

is reported.

With

     ;;; -*- lexical-binding: t -*-

     (defvar foo
       (let ((bar t))
        (if bar 1 0)))

The .elc loads without errors.

Joe





           reply	other threads:[~2021-03-04 18:03 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <CAAQMm-85X7hMaYoce-Hw84AL957pQPhi1zZMme2xLrE2CEqmag@mail.gmail.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=868s72re2m.fsf@phe.ftfl.ca \
    --to=jrm@ftfl.ca \
    --cc=46912@debbugs.gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=spinuvit@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).