all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philipp Stephani <p.stephani2@gmail.com>
To: 24359@debbugs.gnu.org, 24360@debbugs.gnu.org
Subject: bug#24360: Patch for byte compilation bugs
Date: Sat, 03 Sep 2016 18:45:27 +0000	[thread overview]
Message-ID: <CAArVCkSg2BGNqkrxzex4UXrgMr+Za79M0-8+Z4eV4Kcz3acpiA@mail.gmail.com> (raw)
In-Reply-To: <handler.24359.B.147292373921430.ack@debbugs.gnu.org>


[-- Attachment #1.1: Type: text/plain, Size: 57 bytes --]

I've attached a patch for the two byte compilation bugs.

[-- Attachment #1.2: Type: text/html, Size: 82 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Stop-calling-byte-compile-log-warning.patch --]
[-- Type: text/x-patch; charset=US-ASCII;  name="0001-Stop-calling-byte-compile-log-warning.patch", Size: 12748 bytes --]

From 17e0a8a85c0e3e7da101219dac448dab42be9315 Mon Sep 17 00:00:00 2001
From: Philipp Stephani <phst@google.com>
Date: Sat, 3 Sep 2016 20:37:47 +0200
Subject: [PATCH] =?UTF-8?q?Stop=20calling=20=E2=80=98byte-compile-log-warn?=
 =?UTF-8?q?ing=E2=80=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

For errors, use ‘byte-compile-report-error’ instead so that the error
is registered and causes compilation to fail (Bug#24359).

For warnings, use ‘byte-compile-warn’ instead so that
‘byte-compile-error-on-warn’ is honored (Bug#24360).

* lisp/emacs-lisp/macroexp.el (macroexp--funcall-if-compiled)
(macroexp--warn-and-return): Use ‘byte-compile-warn’ instead of
‘byte-compile-log-warning’.

* lisp/emacs-lisp/bytecomp.el (byte-compile-form, byte-compile-unfold-bcf)
(byte-compile-setq, byte-compile-funcall): Use
‘byte-compile-report-error’ instead of ‘byte-compile-log-warning’.
(byte-compile-log-warning): Convert comment to documentation
string.  Explain that the function shouldn’t be called directly.
(byte-compile-report-error): Add optional FILL argument.

* lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use)
(cconv--analyze-function, cconv-analyze-form): Use
‘byte-compile-warn’ instead of ‘byte-compile-log-warning’.

* lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand): Use
‘byte-compile-warn’ instead of ‘byte-compile-log-warning’.

* lisp/subr.el (add-to-list): Use ‘byte-compile-report-error’ instead
of ‘byte-compile-log-warning’.
(do-after-load-evaluation): Use ‘byte-compile-warn’ instead of
‘byte-compile-log-warning’.
---
 lisp/emacs-lisp/byte-opt.el |  4 ++--
 lisp/emacs-lisp/bytecomp.el | 39 ++++++++++++++++++++-------------------
 lisp/emacs-lisp/cconv.el    | 33 ++++++++++++++++-----------------
 lisp/emacs-lisp/macroexp.el |  4 ++--
 lisp/subr.el                |  4 ++--
 5 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index dbaf2bc..610c3b6 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -288,8 +288,8 @@ byte-compile-inline-expand
            (if (eq (car-safe newfn) 'function)
                (byte-compile-unfold-lambda `(,(cadr newfn) ,@(cdr form)))
              ;; This can happen because of macroexp-warn-and-return &co.
-             (byte-compile-log-warning
-              (format "Inlining closure %S failed" name))
+             (byte-compile-warn
+              "Inlining closure %S failed" name)
              form))))
 
       (_ ;; Give up on inlining.
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 175690a..628f7cb 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1160,9 +1160,13 @@ byte-compile-log-file
 	   (compilation-forget-errors)
 	   pt))))
 
-;; Log a message STRING in `byte-compile-log-buffer'.
-;; Also log the current function and file if not already done.
 (defun byte-compile-log-warning (string &optional fill level)
+  "Log a message STRING in `byte-compile-log-buffer'.
+Also log the current function and file if not already done.  If
+FILL is non-nil, set ‘warning-fill-prefix’ to four spaces.  LEVEL
+is the warning level (‘:warning’ or ‘:error’).  Do not call this
+function directly; use ‘byte-compile-warn’ or
+‘byte-compile-report-error’ instead."
   (let ((warning-prefix-function 'byte-compile-warning-prefix)
 	(warning-type-format "")
 	(warning-fill-prefix (if fill "    ")))
@@ -1186,15 +1190,16 @@ byte-compile-warn-obsolete
       (unless (and funcp (memq symbol byte-compile-not-obsolete-funcs))
 	(byte-compile-warn "%s" msg)))))
 
-(defun byte-compile-report-error (error-info)
+(defun byte-compile-report-error (error-info &optional fill)
   "Report Lisp error in compilation.
 ERROR-INFO is the error data, in the form of either (ERROR-SYMBOL . DATA)
-or STRING."
+or STRING.  If FILL is non-nil, set ‘warning-fill-prefix’ to four spaces
+when printing the error message."
   (setq byte-compiler-error-flag t)
   (byte-compile-log-warning
    (if (stringp error-info) error-info
      (error-message-string error-info))
-   nil :error))
+   fill :error))
 \f
 ;;; sanity-checking arglists
 
@@ -3025,9 +3030,8 @@ byte-compile-form
           (pcase (cdr form)
             (`(',var . ,_)
              (when (assq var byte-compile-lexical-variables)
-               (byte-compile-log-warning
-                (format-message "%s cannot use lexical var `%s'" fn var)
-                nil :error)))))
+               (byte-compile-report-error
+                (format-message "%s cannot use lexical var `%s'" fn var))))))
         (when (macroexp--const-symbol-p fn)
           (byte-compile-warn "`%s' called as a function" fn))
 	(when (and (byte-compile-warning-enabled-p 'interactive-only)
@@ -3044,9 +3048,8 @@ byte-compile-form
                                                     interactive-only))
 				   (t "."))))
         (if (eq (car-safe (symbol-function (car form))) 'macro)
-            (byte-compile-log-warning
-             (format "Forgot to expand macro %s in %S" (car form) form)
-             nil :error))
+            (byte-compile-report-error
+             (format "Forgot to expand macro %s in %S" (car form) form)))
         (if (and handler
                  ;; Make sure that function exists.
                  (and (functionp handler)
@@ -3143,9 +3146,8 @@ byte-compile-unfold-bcf
       (dotimes (_ (- (/ (1+ fmax2) 2) alen))
         (byte-compile-push-constant nil)))
      ((zerop (logand fmax2 1))
-      (byte-compile-log-warning
-       (format "Too many arguments for inlined function %S" form)
-       nil :error)
+      (byte-compile-report-error
+       (format "Too many arguments for inlined function %S" form))
       (byte-compile-discard (- alen (/ fmax2 2))))
      (t
       ;; Turn &rest args into a list.
@@ -3755,10 +3757,9 @@ byte-compile-setq
          (len (length args)))
     (if (= (logand len 1) 1)
         (progn
-          (byte-compile-log-warning
+          (byte-compile-report-error
            (format-message
-            "missing value for `%S' at end of setq" (car (last args)))
-           nil :error)
+            "missing value for `%S' at end of setq" (car (last args))))
           (byte-compile-form
            `(signal 'wrong-number-of-arguments '(setq ,len))
            byte-compile--for-effect))
@@ -4028,8 +4029,8 @@ byte-compile-funcall
       (progn
         (mapc 'byte-compile-form (cdr form))
         (byte-compile-out 'byte-call (length (cdr (cdr form)))))
-    (byte-compile-log-warning
-     (format-message "`funcall' called with no arguments") nil :error)
+    (byte-compile-report-error
+     (format-message "`funcall' called with no arguments"))
     (byte-compile-form '(signal 'wrong-number-of-arguments '(funcall 0))
                        byte-compile--for-effect)))
 
diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el
index 9f84367..46b5a7f 100644
--- a/lisp/emacs-lisp/cconv.el
+++ b/lisp/emacs-lisp/cconv.el
@@ -325,9 +325,9 @@ cconv-convert
 		(var (if (not (consp binder))
 			 (prog1 binder (setq binder (list binder)))
                        (when (cddr binder)
-                         (byte-compile-log-warning
-                          (format-message "Malformed `%S' binding: %S"
-                                          letsym binder)))
+                         (byte-compile-warn
+                          "Malformed `%S' binding: %S"
+                          letsym binder))
 		       (setq value (cadr binder))
 		       (car binder)))
 		(new-val
@@ -568,8 +568,8 @@ cconv--analyze-use
     (`(,_ nil nil nil nil) nil)
     (`((,(and var (guard (eq ?_ (aref (symbol-name var) 0)))) . ,_)
        ,_ ,_ ,_ ,_)
-     (byte-compile-log-warning
-      (format-message "%s `%S' not left unused" varkind var))))
+     (byte-compile-warn
+      "%s `%S' not left unused" varkind var)))
   (pcase vardata
     (`((,var . ,_) nil ,_ ,_ nil)
      ;; FIXME: This gives warnings in the wrong order, with imprecise line
@@ -581,8 +581,8 @@ cconv--analyze-use
               (eq ?_ (aref (symbol-name var) 0))
 	      ;; As a special exception, ignore "ignore".
 	      (eq var 'ignored))
-       (byte-compile-log-warning (format-message "Unused lexical %s `%S'"
-                                                 varkind var))))
+       (byte-compile-warn "Unused lexical %s `%S'"
+                          varkind var)))
     ;; If it's unused, there's no point converting it into a cons-cell, even if
     ;; it's captured and mutated.
     (`(,binder ,_ t t ,_)
@@ -606,9 +606,9 @@ cconv--analyze-function
     (dolist (arg args)
       (cond
        ((byte-compile-not-lexical-var-p arg)
-        (byte-compile-log-warning
-         (format "Lexical argument shadows the dynamic variable %S"
-                 arg)))
+        (byte-compile-warn
+         "Lexical argument shadows the dynamic variable %S"
+         arg))
        ((eq ?& (aref (symbol-name arg) 0)) nil) ;Ignore &rest, &optional, ...
        (t (let ((varstruct (list arg nil nil nil nil)))
             (cl-pushnew arg byte-compile-lexical-variables)
@@ -690,9 +690,8 @@ cconv-analyze-form
        (setq forms (cddr forms))))
 
     (`((lambda . ,_) . ,_)             ; First element is lambda expression.
-     (byte-compile-log-warning
-      (format "Use of deprecated ((lambda %s ...) ...) form" (nth 1 (car form)))
-      t :warning)
+     (byte-compile-warn
+      "Use of deprecated ((lambda %s ...) ...) form" (nth 1 (car form)))
      (dolist (exp `((function ,(car form)) . ,(cdr form)))
        (cconv-analyze-form exp env)))
 
@@ -701,8 +700,8 @@ cconv-analyze-form
        (dolist (form forms) (cconv-analyze-form form env))))
 
     ;; ((and `(quote ,v . ,_) (guard (assq v env)))
-    ;;  (byte-compile-log-warning
-    ;;   (format-message "Possible confusion variable/symbol for `%S'" v)))
+    ;;  (byte-compile-warn
+    ;;   "Possible confusion variable/symbol for `%S'" v))
 
     (`(quote . ,_) nil)                 ; quote form
     (`(function . ,_) nil)              ; same as quote
@@ -719,8 +718,8 @@ cconv-analyze-form
     (`(condition-case ,var ,protected-form . ,handlers)
      (cconv-analyze-form protected-form env)
      (when (and var (symbolp var) (byte-compile-not-lexical-var-p var))
-       (byte-compile-log-warning
-        (format "Lexical variable shadows the dynamic variable %S" var)))
+       (byte-compile-warn
+        "Lexical variable shadows the dynamic variable %S" var))
      (let* ((varstruct (list var nil nil nil nil)))
        (if var (push varstruct env))
        (dolist (handler handlers)
diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el
index 310ca29..6d89145 100644
--- a/lisp/emacs-lisp/macroexp.el
+++ b/lisp/emacs-lisp/macroexp.el
@@ -103,7 +103,7 @@ macroexp--compiler-macro
 (defun macroexp--funcall-if-compiled (_form)
   "Pseudo function used internally by macroexp to delay warnings.
 The purpose is to delay warnings to bytecomp.el, so they can use things
-like `byte-compile-log-warning' to get better file-and-line-number data
+like `byte-compile-warn' to get better file-and-line-number data
 and also to avoid outputting the warning during normal execution."
   nil)
 (put 'macroexp--funcall-if-compiled 'byte-compile
@@ -122,7 +122,7 @@ macroexp--compiling-p
 (defvar macroexp--warned (make-hash-table :test #'equal :weakness 'key))
 
 (defun macroexp--warn-and-return (msg form &optional compile-only)
-  (let ((when-compiled (lambda () (byte-compile-log-warning msg t))))
+  (let ((when-compiled (lambda () (byte-compile-warn "%s" msg))))
     (cond
      ((null msg) form)
      ((macroexp--compiling-p)
diff --git a/lisp/subr.el b/lisp/subr.el
index 96917b9..e913e37 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1635,7 +1635,7 @@ add-to-list
                           ;; FIXME: We should also emit a warning for let-bound
                           ;; variables with dynamic binding.
                           (when (assq sym byte-compile--lexical-environment)
-                            (byte-compile-log-warning msg t :error))))
+                            (byte-compile-report-error msg :fill))))
                (code
                 (macroexp-let2 macroexp-copyable-p x element
                   `(if ,(if compare-fn
@@ -4058,7 +4058,7 @@ do-after-load-evaluation
 				       (expand-file-name
 					byte-compile-current-file
 					byte-compile-root-dir)))
-	    (byte-compile-log-warning msg))
+	    (byte-compile-warn "%s" msg))
 	(run-with-timer 0 nil
 			(lambda (msg)
 			  (message "%s" msg))
-- 
2.8.0.rc3.226.g39d4020


  parent reply	other threads:[~2016-09-03 18:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-03 17:28 bug#24359: 25.1; batch-byte-compile exits with code 0 even if errors occurred Philipp
     [not found] ` <handler.24359.B.147292373921430.ack@debbugs.gnu.org>
2016-09-03 18:45   ` Philipp Stephani [this message]
2016-09-04  7:33     ` bug#24359: bug#24360: Patch for byte compilation bugs martin rudalics
2016-09-04  8:45       ` bug#24360: " Andreas Schwab
2016-09-04  9:34         ` martin rudalics
2016-09-04  8:56       ` Philipp Stephani
2016-09-04  9:35         ` martin rudalics
2016-09-04 10:40           ` Andreas Schwab
2016-09-04 11:22             ` martin rudalics
2016-09-04 21:07     ` bug#24359: " npostavs
2016-09-11 16:05       ` Philipp Stephani
2016-09-11 16:36         ` npostavs
2016-10-08 23:53         ` npostavs

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAArVCkSg2BGNqkrxzex4UXrgMr+Za79M0-8+Z4eV4Kcz3acpiA@mail.gmail.com \
    --to=p.stephani2@gmail.com \
    --cc=24359@debbugs.gnu.org \
    --cc=24360@debbugs.gnu.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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.