GNU bug report logs - #33828
26.1; Unbound defvar across compilation units

Previous Next

Package: emacs;

Reported by: Luís Oliveira <luismbo <at> gmail.com>

Date: Fri, 21 Dec 2018 16:23:02 UTC

Severity: minor

Tags: notabug

Found in version 26.1

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Luís Oliveira <luismbo <at> gmail.com>
To: 33828 <at> debbugs.gnu.org
Cc: João Távora <joaotavora <at> gmail.com>
Subject: bug#33828: 26.1; Unbound defvar across compilation units
Date: Fri, 21 Dec 2018 12:02:55 +0000
Hello,

I think I've come across a bug.

    $ cat f1.el
    ;;; f1.el ---                                        -*-
lexical-binding: t; -*-
    ;;; Lexical binding is set to T, but the bug happens regardless.

    (defvar my-special)

    (provide 'f1)


    $ cat f2.el
    ;;; f2.el ---                                        -*-
lexical-binding: t; -*-

    (require 'f1)

    (defun f2-foo ()
      (let ((my-special 123))
        (f2-bar)))

    (defun f2-bar ()
      my-special)

    (print (f2-bar))



    $ emacs -Q -L . -f batch-byte-compile f2.el

    In toplevel form:
    f2.el:5:1:Warning: Unused lexical variable `my-special'

    In f2-bar:
    f2.el:10:3:Warning: reference to free variable `my-special'


Also:

    $ emacs -Q -L . -batch -l f2.el
    Symbol's value as variable is void: my-special


Changing f1.el's defvar to have an initial value makes the problem go
away, but this behaviour was unexpected to me. Moving defvar inside
f2.el also fixes it.

Cheers,
Luís




This bug report was last modified 6 years and 152 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.