From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Cc: "Mattias Engdegård" <mattiase@acm.org>
Subject: Re: master 0a57dfcff8d 2/2: Ensure that specbind arg is always bare symbol, and drop check
Date: Fri, 19 Apr 2024 21:48:47 -0400 [thread overview]
Message-ID: <jwv4jbwst4d.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <20240418115910.3182CC1FB65@vcs2.savannah.gnu.org> ("Mattias Engdegård via Mailing list for Emacs changes"'s message of "Thu, 18 Apr 2024 07:59:10 -0400 (EDT)")
> Ensure that specbind arg is always bare symbol, and drop check
>
> * src/eval.c (FletX, Flet, internal_lisp_condition_case)
> (funcall_lambda): Ensure that the first argument to `specbind` is
> a bare symbol in the few cases where this isn't statically guaranteed.
> (specbind): Drop the symbol argument type check on the fast path.
Shouldn't we signal an error if the first arg to `specbind` is a sympos
instead of bending over backward to accommodate incorrect use?
Maybe I'm missing some context, but IIRC we had concluded that if sympos
reach actual evaluation it's a sign of a bug upstream.
Stefan
> ---
> src/eval.c | 19 +++++++++----------
> 1 file changed, 9 insertions(+), 10 deletions(-)
>
> diff --git a/src/eval.c b/src/eval.c
> index 7f7a70b15ae..c5b8a375af4 100644
> --- a/src/eval.c
> +++ b/src/eval.c
> @@ -948,8 +948,9 @@ usage: (let* VARLIST BODY...) */)
> val = eval_sub (Fcar (XCDR (elt)));
> }
>
> - if (!NILP (lexenv) && SYMBOLP (var)
> - && !XSYMBOL (var)->u.s.declared_special
> + var = maybe_remove_pos_from_symbol (var);
> + if (!NILP (lexenv) && BARE_SYMBOL_P (var)
> + && !XBARE_SYMBOL (var)->u.s.declared_special
> && NILP (Fmemq (var, Vinternal_interpreter_environment)))
> /* Lexically bind VAR by adding it to the interpreter's binding
> alist. */
> @@ -1016,11 +1017,10 @@ usage: (let VARLIST BODY...) */)
> varlist = XCAR (args);
> for (argnum = 0; argnum < nvars && CONSP (varlist); argnum++)
> {
> - Lisp_Object var;
> -
> elt = XCAR (varlist);
> varlist = XCDR (varlist);
> - var = SYMBOLP (elt) ? elt : Fcar (elt);
> + Lisp_Object var = maybe_remove_pos_from_symbol (SYMBOLP (elt) ? elt
> + : Fcar (elt));
> tem = temps[argnum];
>
> if (!NILP (lexenv) && SYMBOLP (var)
> @@ -1416,6 +1416,7 @@ internal_lisp_condition_case (Lisp_Object var, Lisp_Object bodyform,
> struct handler *oldhandlerlist = handlerlist;
> ptrdiff_t CACHEABLE clausenb = 0;
>
> + var = maybe_remove_pos_from_symbol (var);
> CHECK_SYMBOL (var);
>
> Lisp_Object success_handler = Qnil;
> @@ -3254,7 +3255,7 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs, Lisp_Object *arg_vector)
> lexenv = Fcons (Fcons (next, arg), lexenv);
> else
> /* Dynamically bind NEXT. */
> - specbind (next, arg);
> + specbind (maybe_remove_pos_from_symbol (next), arg);
> previous_rest = false;
> }
> }
> @@ -3466,10 +3467,8 @@ do_specbind (struct Lisp_Symbol *sym, union specbinding *bind,
> void
> specbind (Lisp_Object symbol, Lisp_Object value)
> {
> - struct Lisp_Symbol *sym;
> -
> - CHECK_SYMBOL (symbol);
> - sym = XSYMBOL (symbol);
> + /* The caller must ensure that the SYMBOL argument is a bare symbol. */
> + struct Lisp_Symbol *sym = XBARE_SYMBOL (symbol);
>
> start:
> switch (sym->u.s.redirect)
next parent reply other threads:[~2024-04-20 1:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <171344154944.7691.6557554183289684123@vcs2.savannah.gnu.org>
[not found] ` <20240418115910.3182CC1FB65@vcs2.savannah.gnu.org>
2024-04-20 1:48 ` Stefan Monnier [this message]
2024-04-20 7:29 ` master 0a57dfcff8d 2/2: Ensure that specbind arg is always bare symbol, and drop check Mattias Engdegård
2024-04-20 12:34 ` Alan Mackenzie
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwv4jbwst4d.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=mattiase@acm.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).