1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

Prevent shorthand inheritance when loading .elc files (bug#79485)

Loading .elc files doesn't go through 'load-with-code-conversion' as
usual, but since these files are still 'read', we must still take care
to bind read-symbol-shorthands to nil around that.  The process is
simpler than in 'load-with-code-conversion' because .elc files cannot
have read-symbol-shorthands cookies, so the binding is always to nil.
If we don't do this, the symbols in the .elc will be subject to
shorthand manipulation if there's an active binding in the recursive
load stack.

* src/lread.c (readevalloop): Bind read-symbol-shorthands to nil.
(syms_of_lread): Add Qread_symbol_shorthands.
This commit is contained in:
João Távora 2025-10-23 22:34:38 +01:00
parent 94a4bf8a39
commit f47824106a

View file

@ -2207,6 +2207,12 @@ readevalloop (Lisp_Object readcharfun,
specbind (Qstandard_input, readcharfun);
/* In an .elc file, all shorthand expansion has alreay taken place, so
make sure we disable any read-symbol-shorthands set higher up in
the stack of recursive 'load'. */
if (STRINGP (sourcename) && suffix_p (sourcename, ".elc"))
specbind (Qread_symbol_shorthands, Qnil);
/* If lexical binding is active (either because it was specified in
the file's header, or via a buffer-local variable), create an empty
lexical environment, otherwise, turn off lexical binding. */
@ -5907,6 +5913,7 @@ will use instead of `load-path' to look for the file to load. */);
doc: /* Function to decide default lexical-binding. */);
Vinternal__get_default_lexical_binding_function = Qnil;
DEFSYM (Qread_symbol_shorthands, "read-symbol-shorthands");
DEFVAR_LISP ("read-symbol-shorthands", Vread_symbol_shorthands,
doc: /* Alist of known symbol-name shorthands.
This variable's value can only be set via file-local variables.