• Florian Margaine's avatar
    Fix INCF on a THE variable. · 09899a3e
    Florian Margaine authored
    The following code:
    (let ((foo 0))
      (incf (the fixnum foo) (bar)))
    was being expanded into:
    (let ((foo 0))
      (LET* ((#:G133 (BAR)) (#:G132 (THE FIXNUM (+ (THE FIXNUM FOO) (BAR)))))
        (DECLARE (:READ-ONLY #:G133))
        (SETQ FOO (THE FIXNUM #:G132))))
    Which is obviously going to call (BAR) twice. If (BAR) has
    side-effects, then it is going to be buggy.
    The old define-modify-macro had an issue with out-of-order INCF/DECF,
    which is why it was replaced with Bruno Haible's macro, which is
    supposed to improve THE handling. It turns out that the improvement is
    a bit broken, so we're just fixing this.
    Fixes #401.
setf.lsp 31.1 KB