1.0.40.3: better non-ctor make-instance
[sbcl.git] / tests / loop.pure.lisp
index 917731a..84a833a 100644 (file)
@@ -33,7 +33,8 @@
 ;;; a bug reported and fixed by Alexey Dejneka sbcl-devel 2001-10-05:
 ;;; The type declarations should apply, hence under Python's
 ;;; declarations-are-assertions rule, the code should signal a type
-;;; error.
+;;; error. (Except when running interpreted code)
+#+#.(cl:if (cl:eq sb-ext:*evaluator-mode* :compile) '(and) '(or))
 (assert (typep (nth-value 1
                           (ignore-errors
                             (funcall (lambda ()
   (setf (gethash 7 ht) 15)
   (assert (= (loop for v fixnum being each hash-key in ht sum v) 8))
   (assert (= (loop for v fixnum being each hash-value in ht sum v) 18))
+  #+#.(cl:if (cl:eq sb-ext:*evaluator-mode* :compile) '(and) '(or))
   (assert (raises-error? (loop for v float being each hash-value in ht sum v)
                          type-error)))
 
       (macroexpand '(LOOP WITH A = 0 FOR A DOWNFROM 10 TO 0 DO (PRINT A))))
   (declare (ignore _))
   (assert (typep condition 'program-error)))
+
+;;; Loop variable with a range excluding 0, reported by Andras Simon.
+;;; (Used to signal an error during macroexpansion.)
+(assert (not (loop with foo of-type (single-float 1.0 2.0) = 1.5 do (return))))
+
+;;; 1.0.26.12 used to signal a bogus type error for this.
+(loop with x of-type (simple-vector 1) = (make-array '(1))
+      repeat 1
+      return x)
+
+(with-test (:name :bug-540186)
+  (let ((fun (compile nil `(lambda (x)
+                             (loop for i from 0 below (length x)
+                                   for vec of-type vector = (aref x i)
+                                   collect vec)))))
+    (assert (equal '("foo" "bar")
+             (funcall fun
+                      (vector "foo" "bar"))))))