diff --git a/compiler/constraint.lisp b/compiler/constraint.lisp
index 56659409020f8729a286d2c7a02b5dc75a1ff61a..ab6a4530a6f7e91e0b477f6977803afc5bd121b7 100644
--- a/compiler/constraint.lisp
+++ b/compiler/constraint.lisp
@@ -313,12 +313,12 @@
   (let ((var-cons (copy-sset constraints)))
     (sset-intersection var-cons in)
     (let ((res (single-value-type (node-derived-type ref)))
-	  (not-res *empty-type*))
+	  (not-res *empty-type*)
+	  (leaf (ref-leaf ref)))
       (do-elements (con var-cons)
 	(let* ((x (constraint-x con))
 	       (y (constraint-y con))
 	       (not-p (constraint-not-p con))
-	       (leaf (ref-leaf ref))
 	       (other (if (eq x leaf) y x))
 	       (kind (constraint-kind con)))
 	  (case kind