Raymond Toy pushed to branch issue-287-clean-up-make-float-aux at cmucl / cmucl Commits: 9d01b5ca by Raymond Toy at 2024-03-23T12:38:44-07:00 Oops. Need handler-case to catch errors from large numbers. For large numbers that weren't caught the with the rough check, the conversion of the large ratio to a float signals a `simple-type-error` from `coerce`. We need to catch that and signal a `reader-error`. - - - - - 2 changed files: - src/code/reader.lisp - src/i18n/locale/cmucl.pot Changes: ===================================== src/code/reader.lisp ===================================== @@ -1868,17 +1868,20 @@ the end of the stream." float-format (read-buffer-to-string))))))) ;; Otherwise the number might fit, so we carefully compute the result. - (with-float-traps-masked (:underflow) - (let* ((ratio (/ (* (expt 10 exponent) number) - divisor)) - (result (coerce ratio float-format))) - (when (and (zerop result) (not (zerop number))) - ;; The number we've read is so small that it gets - ;; converted to 0.0, but is not actually zero. Signal an - ;; error. See CLHS 2.3.1.1. - (%reader-error stream _"Number not representable as a ~S: ~S" - float-format (read-buffer-to-string))) - result))) + (handler-case + (with-float-traps-masked (:underflow) + (let* ((ratio (/ (* (expt 10 exponent) number) + divisor)) + (result (coerce ratio float-format))) + (when (and (zerop result) (not (zerop number))) + ;; The number we've read is so small that it gets + ;; converted to 0.0, but is not actually zero. Signal an + ;; error. See CLHS 2.3.1.1. + (error "Underflow")) + result)) + (error () + (%reader-error stream _"Number not representable as a ~S: ~S" + float-format (read-buffer-to-string))))) (defun make-ratio (stream) ===================================== src/i18n/locale/cmucl.pot ===================================== @@ -8731,10 +8731,6 @@ msgstr "" msgid "Number not representable as a ~S: ~S" msgstr "" -#: src/code/reader.lisp -msgid "Underflow" -msgstr "" - #: src/code/reader.lisp msgid "Invalid ratio: ~S/~S" msgstr "" View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/9d01b5ca1b1e93e964f388c3... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/9d01b5ca1b1e93e964f388c3... You're receiving this email because of your account on gitlab.common-lisp.net.