Subject: bug#33828: 26.1; Unbound defvar across compilation units

From: Eli Zaretskii <[email-masked]>
Date: Fri, 21 Dec 2018 22:02:49 +0200

> From: Luís Oliveira <[email-masked]>
> Date: Fri, 21 Dec 2018 12:02:55 +0000
> Cc: João Távora <[email-masked]>
> 
> I think I've come across a bug.

Doesn't look like a bug to me.

>     (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'

That's because you do nothing with the value of f2-bar.

>     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

You need to use defvar in the same file.