* lisp/emacs-lisp/bytecomp.el (bytecomp--custom-declare): Warn about
invalid values for the defcustom :local keyword.
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-test-defcustom-local): New test.
(cherry picked from commit
fb42a253bdcbdc9f8af5f934cab4aa24d5b541bd)
(when (and name
byte-compile-current-file ; only when compiling a whole file
(eq fun 'custom-declare-group))
- (setq byte-compile-current-group name))))
+ (setq byte-compile-current-group name))
+
+ ;; Check :local
+ (when-let ((val (and (eq fun 'custom-declare-variable)
+ (plist-get keyword-args :local)))
+ (_ (not (memq val '(t permanent permanent-only)))))
+ (bytecomp--cus-warn form ":local keyword does not accept %S" val))))
(byte-compile-normal-call form))
(dc 'integerp))
))
+(ert-deftest bytecomp-test-defcustom-local ()
+ (cl-flet ((dc (local) `(defcustom mytest nil "doc" :type 'sexp :local ',local :group 'test)))
+ (bytecomp--with-warning-test
+ (rx ":local keyword does not accept 'symbol") (dc 'symbol))
+ (bytecomp--with-warning-test
+ (rx ":local keyword does not accept \"string\"") (dc "string"))
+ ))
+
(ert-deftest bytecomp-test-defface-spec ()
(cl-flet ((df (spec) `(defface mytest ',spec "doc" :group 'test)))
(bytecomp--with-warning-test