unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#33828: 26.1; Unbound defvar across compilation units
@ 2018-12-21 12:02 Luís Oliveira
  2018-12-21 13:50 ` Luís Oliveira
  2018-12-21 20:02 ` Eli Zaretskii
  0 siblings, 2 replies; 7+ messages in thread
From: Luís Oliveira @ 2018-12-21 12:02 UTC (permalink / raw)
  To: 33828; +Cc: João Távora

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





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-12-23  1:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-21 12:02 bug#33828: 26.1; Unbound defvar across compilation units Luís Oliveira
2018-12-21 13:50 ` Luís Oliveira
2018-12-21 20:02 ` Eli Zaretskii
2018-12-22  2:45   ` João Távora
2018-12-22  7:43     ` Eli Zaretskii
2018-12-22 22:40     ` Philipp Stephani
2018-12-23  1:16       ` João Távora

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).