bug#27340: 26.0.50; byte-compile-delete-errors value changes unexpectedly

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

bug#27340: 26.0.50; byte-compile-delete-errors value changes unexpectedly

Katsumi Yamaoka
Hi,

When loading a certain Lisp module that requires eieio, the value
of `byte-compile-delete-errors' is changed to t (the default nil)
unexpectedly.  For instance:

emacs -batch -Q -l auth-source -eval '(message "%s" byte-compile-delete-errors)'
=> t

Because of this, the byte compiler gets oddly quiet when compiling
a Lisp source on a running Emacs than `batch-byte-compile'.  What
changes the value of `byte-compile-delete-errors' is the following
section of eieio-core.el:

--8<---------------cut here---------------start------------->8---
(cl-defstruct (eieio--class
               (:constructor nil)
               (:constructor eieio--class-make (name))
               (:include cl--class)
               (:copier nil))
  children
  initarg-tuples                  ;; initarg tuples list
  (class-slots nil :type eieio--slot)
  class-allocation-values         ;; class allocated value vector
  default-object-cache ;; what a newly created object would look like.
                       ; This will speed up instantiation time as
                       ; only a `copy-sequence' will be needed, instead of
                       ; looping over all the values and setting them from
                       ; the default.
  options ;; storage location of tagged class option
          ; Stored outright without modifications or stripping
  )
--8<---------------cut here---------------end--------------->8---

Though I don't know why it changes `byte-compile-delete-errors',
I think it's a bug.

Thanks.

In GNU Emacs 26.0.50 (build 1, i686-pc-cygwin, GTK+ Version 3.18.9)
 of 2017-06-12 built on localhost
Windowing system distributor 'The Cygwin/X Project', version 11.0.11900000



Reply | Threaded
Open this post in threaded view
|

bug#27340: 26.0.50; byte-compile-delete-errors value changes unexpectedly

Noam Postavsky-2
found 27340 25.2
tags 27340 + confirmed
quit

Katsumi Yamaoka <[hidden email]> writes:

> When loading a certain Lisp module that requires eieio, the value
> of `byte-compile-delete-errors' is changed to t (the default nil)
> unexpectedly.
[...]
> Though I don't know why it changes `byte-compile-delete-errors',
> I think it's a bug.

It's because of the 'cl-declaim' around that 'cl-defstruct':

    (progn
      ;; Arrange for field access not to bother checking if the access is indeed
      ;; made to an eieio--class object.
      (cl-declaim (optimize (safety 0)))

    (cl-defstruct (eieio--class
      ...
      )
      ;; Set it back to the default value.
      (cl-declaim (optimize (safety 1))))

The problem is that the default (safety 1) value is not default with
respect to byte-compile-delete-errors:

    (defun cl--do-proclaim (spec hist)
        ...
        (let (...
              (safety (assq (nth 1 (assq 'safety (cdr spec)))
                            '((0 t) (1 t) (2 t) (3 nil)))))
           ...
           (if safety (setq cl--optimize-safety (car safety)
                            byte-compile-delete-errors (nth 1 safety)))))



Reply | Threaded
Open this post in threaded view
|

bug#27340: 26.0.50; byte-compile-delete-errors value changes unexpectedly

Katsumi Yamaoka
In reply to this post by Katsumi Yamaoka
On Mon, 12 Jun 2017 07:12:24 -0400, [hidden email] wrote:
> It's because of the 'cl-declaim' around that 'cl-defstruct':

> (progn
>   ;; Arrange for field access not to bother checking if the access is indeed
>   ;; made to an eieio--class object.
>   (cl-declaim (optimize (safety 0)))

> (cl-defstruct (eieio--class
>   ...
>   )
>   ;; Set it back to the default value.
>   (cl-declaim (optimize (safety 1))))

> The problem is that the default (safety 1) value is not default with
> respect to byte-compile-delete-errors:

I see both (cl-declaim..) forms set `byte-compile-delete-errors'
to t.  Thanks.  Then I tried this:

--8<---------------cut here---------------start------------->8---
--- eieio-core.el~ 2017-04-19 22:03:44.676418700 +0000
+++ eieio-core.el 2017-06-15 08:46:36.995604500 +0000
@@ -82,5 +82,7 @@
 (defvar eieio-default-superclass nil)
 
-(progn
+(require 'bytecomp)
+(require 'cl-macs)
+(let ((byte-compile-delete-errors byte-compile-delete-errors))
   ;; Arrange for field access not to bother checking if the access is indeed
   ;; made to an eieio--class object.
--8<---------------cut here---------------end--------------->8---

This solves the problem, though I'm not sure it is the right way.
Loading bytecomp is necessary for `byte-compile-delete-errors',
and cl-macs is necessary not to defer performing cl-declaim,
i.e., to perform cl-declaim while `byte-compile-delete-errors'
is let-bound.

Regards,



Reply | Threaded
Open this post in threaded view
|

bug#27340: 26.0.50; byte-compile-delete-errors value changes unexpectedly

Noam Postavsky-2
Katsumi Yamaoka <[hidden email]> writes:

> -(progn
> +(require 'bytecomp)
> +(require 'cl-macs)
> +(let ((byte-compile-delete-errors byte-compile-delete-errors))
>    ;; Arrange for field access not to bother checking if the access is indeed
>    ;; made to an eieio--class object.
>
> This solves the problem, though I'm not sure it is the right way.
> Loading bytecomp is necessary for `byte-compile-delete-errors',
> and cl-macs is necessary not to defer performing cl-declaim,
> i.e., to perform cl-declaim while `byte-compile-delete-errors'
> is let-bound.

Another possibility is to put `cl-declaim's in (eval-when-compile ...),
this stops them having effect when loading eieieo-core.elc (the process
compiling eieio-core.el would still be affected, but since that is
usually a batch Emacs spawned by make, it doesn't really matter).

--- i/lisp/emacs-lisp/eieio-core.el
+++ w/lisp/emacs-lisp/eieio-core.el
@@ -84,7 +84,7 @@ (defvar eieio-default-superclass nil)
 (progn
   ;; Arrange for field access not to bother checking if the access is indeed
   ;; made to an eieio--class object.
-  (cl-declaim (optimize (safety 0)))
+  (eval-when-compile (cl-declaim (optimize (safety 0))))
 
 (cl-defstruct (eieio--class
                (:constructor nil)
@@ -104,7 +104,7 @@ (cl-defstruct (eieio--class
           ; Stored outright without modifications or stripping
   )
   ;; Set it back to the default value.
-  (cl-declaim (optimize (safety 1))))
+  (eval-when-compile (cl-declaim (optimize (safety 1)))))
 
 



Reply | Threaded
Open this post in threaded view
|

bug#27340: 26.0.50; byte-compile-delete-errors value changes unexpectedly

Katsumi Yamaoka
In reply to this post by Katsumi Yamaoka
On Fri, 16 Jun 2017 07:37:46 -0400, [hidden email] wrote:
> Another possibility is to put `cl-declaim's in (eval-when-compile ...),
> this stops them having effect when loading eieieo-core.elc (the process
> compiling eieio-core.el would still be affected, but since that is
> usually a batch Emacs spawned by make, it doesn't really matter).

At the moment I think this is the best solution.  Thanks.



Reply | Threaded
Open this post in threaded view
|

bug#27340: 26.0.50; byte-compile-delete-errors value changes unexpectedly

Noam Postavsky-2
tags 27340 fixed
close 27340 26.1
quit

Katsumi Yamaoka <[hidden email]> writes:

> On Fri, 16 Jun 2017 07:37:46 -0400, [hidden email] wrote:
>> Another possibility is to put `cl-declaim's in (eval-when-compile ...),
>> this stops them having effect when loading eieieo-core.elc (the process
>> compiling eieio-core.el would still be affected, but since that is
>> usually a batch Emacs spawned by make, it doesn't really matter).
>
> At the moment I think this is the best solution.  Thanks.

I pushed it to master [1: c75eb1030f].

[1: c75eb1030f]: 2017-06-24 10:12:53 -0400
  Don't change byte-compile-delete-errors at runtime (Bug#27340)
  http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=c75eb1030fbb606765cc8a5e5ecbab4a9cf435ed