From f47824106a58f00c8d5e166930f18102b5e96bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Thu, 23 Oct 2025 22:34:38 +0100 Subject: [PATCH] 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. --- src/lread.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lread.c b/src/lread.c index 1a667ce163a..273957507a3 100644 --- a/src/lread.c +++ b/src/lread.c @@ -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.