The branch "master" has been updated in SBCL:
via 63e78fc74df6e60019a9952531c4b7608656f07e (commit)
from 6f4c867e670a3c538b4072b824fa8026e9f2cbfe (commit)
- Log -----------------------------------------------------------------
commit 63e78fc74df6e60019a9952531c4b7608656f07e
Author: Stas Boukarev <stassats@...>
Date: Fri Jan 11 07:38:13 2013 +0400
format: ~R should check a type only if base is not supplied.
(format t "~2r" 1/2) is valid.
---
src/code/late-format.lisp | 3 ++-
src/code/target-format.lisp | 3 ++-
tests/print.impure.lisp | 6 +++++-
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/code/late-format.lisp b/src/code/late-format.lisp
index 9afc2a5..7777866 100644
--- a/src/code/late-format.lisp
+++ b/src/code/late-format.lisp
@@ -513,7 +513,8 @@
params
(let ((n-arg (sb!xc:gensym "ARG")))
`(let ((,n-arg ,(expand-next-arg)))
- (unless (integerp ,n-arg)
+ (unless (or ,base
+ (integerp ,n-arg))
(error 'format-error
:complaint "~s is not of type INTEGER."
:args (list ,n-arg)
diff --git a/src/code/target-format.lisp b/src/code/target-format.lisp
index 399feb0..f8ab91f 100644
--- a/src/code/target-format.lisp
+++ b/src/code/target-format.lisp
@@ -332,7 +332,8 @@
(commainterval 3))
params
(let ((arg (next-arg)))
- (unless (integerp arg)
+ (unless (or base
+ (integerp arg))
(error 'format-error
:complaint "~s is not of type INTEGER."
:args (list arg)))
diff --git a/tests/print.impure.lisp b/tests/print.impure.lisp
index 2e5b391..302fb6e 100644
--- a/tests/print.impure.lisp
+++ b/tests/print.impure.lisp
@@ -646,7 +646,11 @@
(error "Endless loop in FORMAT"))))
(with-test (:name :format-type-check)
+ (assert (equal "1/10" (format nil "~2r" 1/2)))
(assert (raises-error? (format nil "~r" 1.32) sb-format:format-error))
- (assert (raises-error? (format nil "~c" 1.32) sb-format:format-error)))
+ (assert (raises-error? (format nil "~c" 1.32) sb-format:format-error))
+ (assert (equal "1/10" (eval '(format nil "~2r" 1/2))))
+ (assert (raises-error? (eval '(format nil "~r" 1.32)) sb-format:format-error))
+ (assert (raises-error? (eval '(format nil "~c" 1.32)) sb-format:format-error)))
;;; success
-----------------------------------------------------------------------
hooks/post-receive
--
SBCL
|