all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#62889: 29.0.60; (setopt ...) does not give "assignment to free variable" warning
@ 2023-04-16 15:59 ar0x2ff
  2023-04-18  6:18 ` Philip Kaludercic
  0 siblings, 1 reply; 4+ messages in thread
From: ar0x2ff @ 2023-04-16 15:59 UTC (permalink / raw)
  To: 62889


If I open emacs -q and write the following code in a Emacs Lisp buffer:

;;; init.el --- summary

;;; Commentary:

;;; Code:

(setq var1 2)
(customize-set-variable var2 2)
(setopt var3 2)

(provide 'init)
;;; init.el ends here

I'll get the following errors, if i enable FlyMake:

7   6 warning  e-f-b-c  assignment to free variable ‘var1’
8  24 warning  e-f-b-c  reference to free variable ‘var2’

Why setopt is not underlined here? I know it's a new macro introduced in Emacs 
29 but I wonder if it is intended to be like this or the linter is just 
misbehaving here.


In GNU Emacs 29.0.60 (build 1, x86_64-redhat-linux-gnu, GTK+ Version
 3.24.37, cairo version 1.17.6) of 2023-03-14 built on
 2cafab91c998469c95c4917f66b01a98
System Description: Fedora Linux 37 (Thirty Seven)

Configured using:
 'configure --build=x86_64-redhat-linux-gnu
 --host=x86_64-redhat-linux-gnu --program-prefix=
 --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr
 --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc
 --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64
 --libexecdir=/usr/libexec --localstatedir=/var
 --sharedstatedir=/var/lib --mandir=/usr/share/man
 --infodir=/usr/share/info --with-dbus --with-gif --with-jpeg --with-png
 --with-rsvg --with-tiff --with-xft --with-xpm --with-gpm=no
 --with-xwidgets --with-modules --with-harfbuzz --with-cairo --with-json
 --with-pgtk --with-native-compilation --enable-link-time-optimization
 build_alias=x86_64-redhat-linux-gnu host_alias=x86_64-redhat-linux-gnu
 CC=gcc 'CFLAGS=-DMAIL_USE_LOCKF -O2 -flto=auto -ffat-lto-objects
 -fexceptions -g -grecord-gcc-switches -pipe -Wall
 -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2
 -Wp,-D_GLIBCXX_ASSERTIONS
 -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong
 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic
 -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection'
 LDFLAGS=-Wl,-z,relro
 PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig CXX=g++
 'CXXFLAGS=-O2 -flto=auto -ffat-lto-objects -fexceptions -g
 -grecord-gcc-switches -pipe -Wall -Werror=format-security
 -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS
 -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong
 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic
 -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection''

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS XIM XWIDGETS GTK3 ZLIB

Important settings:
  value of $LANG: it_IT.UTF-8
  locale-coding-system: utf-8-unix

Major mode: ELisp/d

Minor modes in effect:
  flymake-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/usr/share/emacs/site-lisp/lilypond-init hides /usr/share/emacs/site-lisp/
site-start.d/lilypond-init

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils noutline outline checkdoc lisp-mnt
flymake-proc flymake project byte-opt compile text-property-search
comint ansi-osc ansi-color ring thingatpt time-date cl-loaddefs comp
comp-cstr warnings icons subr-x rx cl-seq cl-macs gv cl-extra help-mode
bytecomp byte-compile cl-lib rmc iso-transl tooltip cconv eldoc paren
electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/pgtk-win pgtk-win term/common-win pgtk-dnd tool-bar dnd fontset
image regexp-opt fringe tabulated-list replace newcomment text-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads xwidget-internal dbusbind
inotify dynamic-setting system-font-setting font-render-setting cairo
gtk pgtk lcms2 multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 101023 9352)
 (symbols 48 8599 0)
 (strings 32 25108 1552)
 (string-bytes 1 788606)
 (vectors 16 18679)
 (vector-slots 8 373173 11952)
 (floats 8 37 38)
 (intervals 56 517 0)
 (buffers 976 16))








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

* bug#62889: 29.0.60; (setopt ...) does not give "assignment to free variable" warning
  2023-04-16 15:59 bug#62889: 29.0.60; (setopt ...) does not give "assignment to free variable" warning ar0x2ff
@ 2023-04-18  6:18 ` Philip Kaludercic
  2023-04-18  8:34   ` ar0x2ff
  0 siblings, 1 reply; 4+ messages in thread
From: Philip Kaludercic @ 2023-04-18  6:18 UTC (permalink / raw)
  To: ar0x2ff; +Cc: 62889

ar0x2ff@gmail.com writes:

> If I open emacs -q and write the following code in a Emacs Lisp buffer:
>
> ;;; init.el --- summary
>
> ;;; Commentary:
>
> ;;; Code:
>
> (setq var1 2)
> (customize-set-variable var2 2)
> (setopt var3 2)
>
> (provide 'init)
> ;;; init.el ends here
>
> I'll get the following errors, if i enable FlyMake:
>
> 7   6 warning  e-f-b-c  assignment to free variable ‘var1’
> 8  24 warning  e-f-b-c  reference to free variable ‘var2’
>
> Why setopt is not underlined here? I know it's a new macro introduced in Emacs 
> 29 but I wonder if it is intended to be like this or the linter is just 
> misbehaving here.

var2 should also not be highlighted, since the first argument to the
function `customize-set-variable' is a symbol, and the byte compiler
correctly states that it doesn't know that any variable "var2" will be
defined.

If you macroexpand setopt, you will see that it generates

  (setopt--set 'var3 2)

which is all fine, since no functions are being invoked with undefined
variables.

The reason this makes sense is that not all user options have to be
loaded when they are set.  A number of them are even auto-loaded and
will load the library for the necessary user-option setters if
necessary.

> In GNU Emacs 29.0.60 (build 1, x86_64-redhat-linux-gnu, GTK+ Version
>  3.24.37, cairo version 1.17.6) of 2023-03-14 built on
>  2cafab91c998469c95c4917f66b01a98
> System Description: Fedora Linux 37 (Thirty Seven)
>
> Configured using:
>  'configure --build=x86_64-redhat-linux-gnu
>  --host=x86_64-redhat-linux-gnu --program-prefix=
>  --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr
>  --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc
>  --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64
>  --libexecdir=/usr/libexec --localstatedir=/var
>  --sharedstatedir=/var/lib --mandir=/usr/share/man
>  --infodir=/usr/share/info --with-dbus --with-gif --with-jpeg --with-png
>  --with-rsvg --with-tiff --with-xft --with-xpm --with-gpm=no
>  --with-xwidgets --with-modules --with-harfbuzz --with-cairo --with-json
>  --with-pgtk --with-native-compilation --enable-link-time-optimization
>  build_alias=x86_64-redhat-linux-gnu host_alias=x86_64-redhat-linux-gnu
>  CC=gcc 'CFLAGS=-DMAIL_USE_LOCKF -O2 -flto=auto -ffat-lto-objects
>  -fexceptions -g -grecord-gcc-switches -pipe -Wall
>  -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2
>  -Wp,-D_GLIBCXX_ASSERTIONS
>  -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong
>  -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic
>  -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection'
>  LDFLAGS=-Wl,-z,relro
>  PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig CXX=g++
>  'CXXFLAGS=-O2 -flto=auto -ffat-lto-objects -fexceptions -g
>  -grecord-gcc-switches -pipe -Wall -Werror=format-security
>  -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS
>  -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong
>  -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic
>  -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection''
>
> Configured features:
> ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
> LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY
> INOTIFY PDUMPER PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
> TOOLKIT_SCROLL_BARS XIM XWIDGETS GTK3 ZLIB
>
> Important settings:
>   value of $LANG: it_IT.UTF-8
>   locale-coding-system: utf-8-unix
>
> Major mode: ELisp/d
>
> Minor modes in effect:
>   flymake-mode: t
>   tooltip-mode: t
>   global-eldoc-mode: t
>   eldoc-mode: t
>   show-paren-mode: t
>   electric-indent-mode: t
>   mouse-wheel-mode: t
>   tool-bar-mode: t
>   menu-bar-mode: t
>   file-name-shadow-mode: t
>   global-font-lock-mode: t
>   font-lock-mode: t
>   blink-cursor-mode: t
>   line-number-mode: t
>   indent-tabs-mode: t
>   transient-mark-mode: t
>   auto-composition-mode: t
>   auto-encryption-mode: t
>   auto-compression-mode: t
>
> Load-path shadows:
> /usr/share/emacs/site-lisp/lilypond-init hides /usr/share/emacs/site-lisp/
> site-start.d/lilypond-init
>
> Features:
> (shadow sort mail-extr emacsbug message mailcap yank-media puny dired
> dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
> epg-config gnus-util mm-decode mm-bodies mm-encode mail-parse rfc2231
> mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
> mm-util mail-prsvr mail-utils noutline outline checkdoc lisp-mnt
> flymake-proc flymake project byte-opt compile text-property-search
> comint ansi-osc ansi-color ring thingatpt time-date cl-loaddefs comp
> comp-cstr warnings icons subr-x rx cl-seq cl-macs gv cl-extra help-mode
> bytecomp byte-compile cl-lib rmc iso-transl tooltip cconv eldoc paren
> electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
> term/pgtk-win pgtk-win term/common-win pgtk-dnd tool-bar dnd fontset
> image regexp-opt fringe tabulated-list replace newcomment text-mode
> lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
> easymenu timer select scroll-bar mouse jit-lock font-lock syntax
> font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
> indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
> tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
> romanian slovak czech european ethiopic indian cyrillic chinese
> composite emoji-zwj charscript charprop case-table epa-hook
> jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
> theme-loaddefs faces cus-face macroexp files window text-properties
> overlay sha1 md5 base64 format env code-pages mule custom widget keymap
> hashtable-print-readable backquote threads xwidget-internal dbusbind
> inotify dynamic-setting system-font-setting font-render-setting cairo
> gtk pgtk lcms2 multi-tty make-network-process native-compile emacs)
>
> Memory information:
> ((conses 16 101023 9352)
>  (symbols 48 8599 0)
>  (strings 32 25108 1552)
>  (string-bytes 1 788606)
>  (vectors 16 18679)
>  (vector-slots 8 373173 11952)
>  (floats 8 37 38)
>  (intervals 56 517 0)
>  (buffers 976 16))





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

* bug#62889: 29.0.60; (setopt ...) does not give "assignment to free variable" warning
  2023-04-18  6:18 ` Philip Kaludercic
@ 2023-04-18  8:34   ` ar0x2ff
  2023-04-18 19:20     ` Philip Kaludercic
  0 siblings, 1 reply; 4+ messages in thread
From: ar0x2ff @ 2023-04-18  8:34 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: 62889

Philip Kaludercic writes: 
> var2 should also not be highlighted, since the first argument to the
> function `customize-set-variable' is a symbol, and the byte compiler
> correctly states that it doesn't know that any variable "var2" will be
> defined.
> 
> If you macroexpand setopt, you will see that it generates
> 
>   (setopt--set 'var3 2)
> 
> which is all fine, since no functions are being invoked with undefined
> variables.
> 
> The reason this makes sense is that not all user options have to be
> loaded when they are set.  A number of them are even auto-loaded and
> will load the library for the necessary user-option setters if
> necessary.

I was aware of the "do not overwrite custom variable if set before library 
load" mechanism, but I also seem to remember the (customize-set-variable ...) 
function to throw "free variable" warnings (e.g. when i open custome.el), so i 
kind of took for granted that it was correct behaviour.

Glad to know (setopt ...) works this way! No more warning suppress in my init 
file :)









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

* bug#62889: 29.0.60; (setopt ...) does not give "assignment to free variable" warning
  2023-04-18  8:34   ` ar0x2ff
@ 2023-04-18 19:20     ` Philip Kaludercic
  0 siblings, 0 replies; 4+ messages in thread
From: Philip Kaludercic @ 2023-04-18 19:20 UTC (permalink / raw)
  To: ar0x2ff; +Cc: 62889-done

ar0x2ff@gmail.com writes:

> Philip Kaludercic writes: 
>> var2 should also not be highlighted, since the first argument to the
>> function `customize-set-variable' is a symbol, and the byte compiler
>> correctly states that it doesn't know that any variable "var2" will be
>> defined.
>> 
>> If you macroexpand setopt, you will see that it generates
>> 
>>   (setopt--set 'var3 2)
>> 
>> which is all fine, since no functions are being invoked with undefined
>> variables.
>> 
>> The reason this makes sense is that not all user options have to be
>> loaded when they are set.  A number of them are even auto-loaded and
>> will load the library for the necessary user-option setters if
>> necessary.
>
> I was aware of the "do not overwrite custom variable if set before library 
> load" mechanism, but I also seem to remember the (customize-set-variable ...) 
> function to throw "free variable" warnings (e.g. when i open custome.el), so i 
> kind of took for granted that it was correct behaviour.
>
> Glad to know (setopt ...) works this way! No more warning suppress in my init 
> file :)

Great, then I will close the report.





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

end of thread, other threads:[~2023-04-18 19:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-16 15:59 bug#62889: 29.0.60; (setopt ...) does not give "assignment to free variable" warning ar0x2ff
2023-04-18  6:18 ` Philip Kaludercic
2023-04-18  8:34   ` ar0x2ff
2023-04-18 19:20     ` Philip Kaludercic

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.