Unused lexical variable


#1

运行这个函数的时候会出现unused lexical variablewarning。 警告里的都是let binding里的变量,但是我后面都使用了这些变量。就算我给所有变量 都用ignore强行“用”了一遍以后还是报警,这是为啥啊?

而且dolist也报错是什么鬼……

(defun uikit-autolayout (stackview)
  "Ask STACKVIEW to auto layout."
  (let* ((orientation-index (pcase (uikit--orientation-of stackview)
                              ('left 0) ; rotate clockwise 0 degree
                              ('bottom 1) ; rotate 90 degree
                              ('right 2) ; 180 degree
                              ('top 3))) ; 270 degree
         (last-left (byte-compile (lambda (SELF) (ignore SELF) (uikit-left-of stackview))))
         (space-func (pcase (uikit--autolayout-of stackview)
                       ('stacking (byte-compile (lambda () (uikit--stacking-space-of stackview))))
                       ('equal-spacing (byte-compile (lambda () (uikit--equal-spacing-space stackview))))))
         (top-func (pcase (uikit--v-align-of stackview)
                     ('top (lambda (SELF) (uikit-top-of (uikit--parent-stackview-of SELF))))
                     ('center (lambda (SELF)
                                (+ (uikit-top-of (uikit--parent-stackview-of SELF))
                                   (/ (- (uikit--max-subview-height (uikit--parent-stackview-of SELF))
                                         (uikit-content-height-of SELF)) 2))))
                     ('bottom (lambda (SELF)
                                (- (uikit-bottom-of (uikit--parent-stackview-of SELF))
                                   (uikit-content-width-of SELF)))))))
    (let ((uikit-left-of (nth orientation-index '(uikit-left-of uikit-bottom-of uikit-right-of uikit-top-of)))
          (uikit-bottom-of (nth orientation-index '(uikit-bottom-of uikit-right-of uikit-top-of uikit-left-of)))
          (uikit-right-of (nth orientation-index '(uikit-right-of uikit-top-of uikit-left-of uikit-bottom-of)))
          (uikit-top-of (nth orientation-index '(uikit-top-of uikit-left-of uikit-bottom-of uikit-right-of))))
      ;; ??? unused lexical variable xxx
      (ignore last-left space-func top-func)
      ;; during the drawing process `uikit-<constrain>-of' will be
      ;; bind to another function that calculates the constrain into
      ;; actual number and saves to cache
      (dolist (subview (uikit--subview-list-of stackview))
        ;; autolayout yourself if you are a stackview
        (when (cl-typep subview 'uikit-stackview)
          (uikit-autolayout subview))
        ;; set your parent
        (setf (uikit--parent-stackview-of subview) stackview)
        ;; set your left to the right of the previous view
        (uikit-left-of subview last-left)
        (setq last-left (byte-compile (lambda (SELF) (ignore SELF)
                                        (+ (uikit-right-of subview)
                                           (funcall space-func)))))
        ;; top & bottom
        (uikit-top-of subview top-func)))))

Warning: Unused lexical variable ‘orientation-index’
Warning: Unused lexical variable ‘orientation-index’
Warning: Unused lexical variable ‘last-left’
Warning: Unused lexical variable ‘stackview’
Warning: Unused lexical variable ‘orientation-index’
Warning: Unused lexical variable ‘last-left’
Warning: Unused lexical variable ‘top-func’
Warning: Unused lexical variable ‘uikit-left-of’
Warning: Unused lexical variable ‘uikit-bottom-of’
Warning: Unused lexical variable ‘uikit-right-of’
Warning: Unused lexical variable ‘uikit-top-of’
Warning: Unused lexical variable ‘--dolist-tail--’
Warning: Unused lexical variable ‘stackview’
Warning: Unused lexical variable ‘orientation-index’
Warning: Unused lexical variable ‘last-left’
Warning: Unused lexical variable ‘top-func’
Warning: Unused lexical variable ‘uikit-left-of’
Warning: Unused lexical variable ‘uikit-bottom-of’
Warning: Unused lexical variable ‘uikit-right-of’
Warning: Unused lexical variable ‘uikit-top-of’
Warning: Unused lexical variable ‘--dolist-tail--’

#2

你可以先跑一下,然后结果和你预期有出入,修复后可能就没了。