]> git.eshelyaron.com Git - emacs.git/commitdiff
Stop calling ‘byte-compile-log-warning’
authorPhilipp Stephani <phst@google.com>
Sat, 3 Sep 2016 18:37:47 +0000 (20:37 +0200)
committerPhilipp Stephani <phst@google.com>
Sun, 11 Sep 2016 16:12:33 +0000 (18:12 +0200)
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
lisp/emacs-lisp/bytecomp.el
lisp/emacs-lisp/cconv.el
lisp/emacs-lisp/macroexp.el
lisp/subr.el

index dbaf2bc6f6ab181d5e9f3b46af510ecdf49b2d00..610c3b6c190e3b2d54d47b395495f242cc6bb17a 100644 (file)
            (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.
index 175690af3e8cc34f571eaa1182f61c295358b935..b6bb1d6ab906ed24fbdaff6fd93100774025ce2a 100644 (file)
@@ -1160,9 +1160,13 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'."
           (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 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'."
       (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 @@ for symbols generated by the byte compiler itself."
           (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 @@ for symbols generated by the byte compiler itself."
                                                     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 @@ for symbols generated by the byte compiler itself."
       (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 @@ discarding."
          (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 @@ that suppresses all warnings during execution of BODY."
       (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)))
 
index 9f84367635711800e62eae5f544c7313ae8af21b..46b5a7f342cfcd47558146d5cfbd6a2b2983d9b4 100644 (file)
@@ -325,9 +325,9 @@ places where they originally did not directly appear."
                (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 @@ FORM is the parent form that binds this var."
     (`(,_ 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 @@ FORM is the parent form that binds this var."
               (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 @@ FORM is the parent form that binds this var."
     (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 @@ and updates the data stored in ENV."
        (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 @@ and updates the data stored in ENV."
        (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 @@ and updates the data stored in ENV."
     (`(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)
index 310ca29e9a1cf4a7f0c88916905fa1a50bf08c5a..6d89145c6a2875dd92f637389ffd4dbb9ea5e7c6 100644 (file)
@@ -103,7 +103,7 @@ each clause."
 (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 @@ and also to avoid outputting the warning during normal execution."
 (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)
index 96917b9ea96290c206b29ab0b545c18d67055ea5..e913e378500ad80d2a08ecde65e9acabe94e6194 100644 (file)
@@ -1635,7 +1635,7 @@ can do the job."
                           ;; 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 @@ This function is called directly from the C code."
                                       (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))