Subject: bug#54399: 27.2; Problems with (let ((custom-variable ...)) (autoload-function ...))

From: Stefan Monnier <[email-masked]>
Date: Tue, 12 Apr 2022 09:18:03 -0400

>   (setq lexical-binding nil)
>   (let ((another-fresh-var 1))
>     (default-boundp 'another-fresh-var)) ;; I expect nil, it returns t

This means you misunderstand dynamic scoping or the meaning of
"default-" in `default-boundp` (it has nothing to do with let bindings
but is only concerned about buffer-local or not).

If you disregard lexical scoping, there are kinda to dimensions to
locality of variables: there's the "let" locality and there's the
"buffer" locality.  They can be combined.  `default-boundp/set-default`
only differ from `boundp/set` on the "buffer" dimension of locality.

Lexical scoping is yet a different beast because lexical variables have
fundamentally no name, so a lexical binding of variable `foo` has no
relation to what `boundp/set` see when passed `foo` as argument.

        Stefan