Changeset 14356


Ignore:
Timestamp:
01/16/13 10:48:24 (11 years ago)
Author:
Mark Evenson
Message:

Backport r14355 | mevenson | 2013-01-16 11:45:54 +0100 (Wed, 16 Jan 2013) | 5 lines.

Fix loop and default value for of-type problem.

Patch and (most of) test by Stas.

Fixes #293.

Location:
branches/1.1.x
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.1.x/src/org/armedbear/lisp/loop.lisp

    r11391 r14356  
    987987(defun loop-typed-init (data-type &optional step-var-p)
    988988  (when (and data-type (subtypep data-type 'number))
    989     (if (or (subtypep data-type 'float)
    990       (subtypep data-type '(complex float)))
    991   (coerce (if step-var-p 1 0) data-type)
    992   (if step-var-p 1 0))))
     989    ;; From SBCL
     990    (let ((init (if step-var-p 1 0)))
     991      (flet ((like (&rest types)
     992               (coerce init (find-if (lambda (type)
     993                                       (subtypep data-type type))
     994                                     types))))
     995        (cond ((subtypep data-type 'float)
     996               (like 'single-float 'double-float
     997                     'short-float 'long-float 'float))
     998              ((subtypep data-type '(complex float))
     999               (like '(complex single-float)
     1000                     '(complex double-float)
     1001                     '(complex short-float)
     1002                     '(complex long-float)
     1003                     '(complex float)))
     1004              (t
     1005               init))))))
    9931006
    9941007(defun loop-optional-type (&optional variable)
  • branches/1.1.x/test/lisp/abcl/bugs.lisp

    r14248 r14356  
    126126  (probe-file (make-pathname :device (list "foo")))
    127127nil)
     128
     129;; http://trac.common-lisp.net/armedbear/ticket/293
     130(deftest bugs.loop.1
     131    (loop :with x :of-type (float 0) = 0.0
     132       :for y :upto 1
     133       :collecting (cons x y))
     134  ((0.0 . 0) (0.0 . 1)))
     135
Note: See TracChangeset for help on using the changeset viewer.