GNU bug report logs - #54079
29.0.50; Method dispatching eratically fails

Previous Next

Package: emacs;

Reported by: Michael Heerdegen <michael_heerdegen <at> web.de>

Date: Mon, 21 Feb 2022 00:14:02 UTC

Severity: normal

Found in version 29.0.50

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


Message #83 received at 54079 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Alan Mackenzie <acm <at> muc.de>
Cc: Michael Heerdegen <michael_heerdegen <at> web.de>,
 Lars Ingebrigtsen <larsi <at> gnus.org>, 54079 <at> debbugs.gnu.org
Subject: Re: bug#54079: 29.0.50; Method dispatching eratically fails
Date: Wed, 09 Mar 2022 13:06:11 -0500
>> I don't understand the scenario you're thinking of.
>> Are you thinking of something like `(eval-when-compile (byte-compile ...))?
> Yes.
>> Does that ever happen in real life?
> Probably exceedingly seldomly.
> What's to be gained by not catering to this unusual case?  What do we
> lose?

We lose making it work right for the 99% other cases that *do* occur?

>> >> And why bother stripping the result of `byte-compile-eval`?
>> > Because it might be the result of evaluating a defun (or defvar or
>> > defconst).
>
>> AFAIK sympos should only appear within the compiler pipeline between the
>> "read" and the "emit resulting bytecode".  They may be passed to various
>> functions and macros along the way, but I can't think of any scenario
>> where they'd end up returned by `(byte-compile-)eval`.
>
>> > This was the situation which gave rise to the bug.
>
>> Could you give some details about how it played out?
>> [ Either here or as a comment in the code.  ]
>
> Michael byte compiled cl-generic.el.  This created cl-generic.elc
> correctly, but also left uncompiled forms in the function cells of the
> symbols defun'd inside an eval-{when,and}-compile.  These forms
> contained symbols with positions.

Hmm... we're talking about stripping the result of `byte-compile-eval`.
This function is only used for `eval-when-compile`, not `eval-and-compile`.
And nothing in your above description indicates that the sympos appeared
in the resulting value of `eval-when-compile` (as opposed to appearing
in the slot of functions and variables that were set during the course
of the evaluation).

>> >> Fundamentally, `eval` should always strip before doing its job.
>> > Except when what it's evaluating is a defun, defmacrro, defsubst, etc.
>> Why?
> Because that evaluated form might later be byte compiled, and the SWPs
> will be needed for that.

I don't understand the scenario you're thinking of.
Are thinking of a case like:

- something causes the execution of (eval '(defun foo ...))
- the user types `M-x byte-compile RET foo RET`

If so, then:
- I don't think we should care about this case because it's extremely
  rare and fundamentally broken (the symbol's function cell contains
  a function *value* (i.e. a closure) and not a function's source code,
  so in general we need `byte-compile--reify-function` which implements
  a heuristic to go back to something like a source form, which can
  break in various ways in corner cases).
- If we don't strip before calling the `M-x byte-compile` then the code
  may/will bisbehave because of the presence of the sympos.


        Stefan





This bug report was last modified 3 years and 67 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.