Subject: Re: bug#34757: Invalid bytecode from byte compiler

From: Pip Cet <[email-masked]>
Date: Fri, 15 Mar 2019 19:40:48 +0000

On Fri, Mar 15, 2019 at 2:08 PM Stefan Monnier <[email-masked]> wrote:
> >> diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
> >> index 0b8f8824b4c..4e54e08ce14 100644
> >> --- a/lisp/emacs-lisp/bytecomp.el
> >> +++ b/lisp/emacs-lisp/bytecomp.el
> >> @@ -3025,6 +3025,7 @@ byte-compile-out-toplevel
> >>                         (or (null (cdr rest))
> >>                             (and (memq output-type '(file progn t))
> >>                                  (cdr (cdr rest))
> >> +                                (eql (length body) (cdr (car rest)))
> >>                                  (eq (car (nth 1 rest)) 'byte-discard)
> >>                                  (progn (setq rest (cdr rest)) t))))
> >>                    (setq maycall nil)    ; Only allow one real function call.
> >
> > Stefan, any comments?
>
> Looks good to me, thanks.
>
> I'm personally running with the following patch instead, which is much
> more risky and hasn't been sufficiently tested yet.

Just to be sure I understand correctly, you would like to remove the
decompilation of trivial function calls entirely?

That seems good to me.

It seems the special case is necessary to avoid compilation errors,
and that it's used for (byte-compile 3), so I think the comment could
be improved a little.

I'm not sure this case can actually happen without doing something
silly, but (byte-compile '(internal-get-closed-var 0)) throws an error
with Stefan's patch, because the byte code is (byte-constant . 0)
(byte-return).