all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philip Kaludercic <philipk@posteo.net>
To: ar0x2ff@gmail.com
Cc: 62889@debbugs.gnu.org
Subject: bug#62889: 29.0.60; (setopt ...) does not give "assignment to free variable" warning
Date: Tue, 18 Apr 2023 06:18:55 +0000	[thread overview]
Message-ID: <87pm813e7k.fsf@posteo.net> (raw)
In-Reply-To: <2678912.mvXUDI8C0e@192.168.1.69> (ar0x2ff@gmail.com's message of "Sun, 16 Apr 2023 17:59:37 +0200")

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





  reply	other threads:[~2023-04-18  6:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2023-04-18  8:34   ` ar0x2ff
2023-04-18 19:20     ` Philip Kaludercic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pm813e7k.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=62889@debbugs.gnu.org \
    --cc=ar0x2ff@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.