dash.el icon indicating copy to clipboard operation
dash.el copied to clipboard

bug: `-if-let` mismatch between documentation and behavior

Open ethan-leba opened this issue 2 years ago • 5 comments

The documentation for -if-let reads as follows: If VAL evaluates to non-nil, bind it to VAR and do THEN, otherwise do ELSE.

However, -if-let's behavior does not match this, and instead appears to match against (part of) var:

(-if-let ((foo . bar) '(3)) 'true 'false) ;; evals to 'false
(if '(3) 'true 'false) ;; evals to 'true

;; if-let macroexpands to:
(let ((--dash-source-98-- '(3)))
  (if --dash-source-98--
      (let ((foo (pop --dash-source-98--)))
        (if foo ;; should be --dash-source-98--
            (let ((bar --dash-source-98--))
              (if bar 'true 'false))
          'false))
    'false))

Thanks for the great package!

ethan-leba avatar Nov 18 '21 23:11 ethan-leba