Subject: bug#56400: Make setopt warn on type mismatch

From: Lars Ingebrigtsen <[email-masked]>
Date: Tue, 05 Jul 2022 18:57:17 +0200

Stefan Kangas <[email-masked]> writes:

> Why not make `setopt' warn in case there is a type mismatch?
> For example, in:
>
>     (setopt tetris-buffer-width "hello")
>
> But the type of `tetris-buffer-width' is natnum.

It should throw an error already:

;;;###autoload
(defun setopt--set (variable value)
  (custom-load-symbol variable)
  ;; Check that the type is correct.
  (when-let ((type (get variable 'custom-type)))
    (unless (widget-apply (widget-convert type) :match value)
      (user-error "Value `%S' does not match type %s" value type)))

Did you mean a byte compilation warning?  I don't really think that
people will be using setopt much in code, just in .emacs, so I'm not
sure that'd give us much.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no