9 Jul 2012 14:29
bug#11887: string->number edge cases
Ian Price <ianprice90 <at> googlemail.com>
2012-07-09 12:29:16 GMT
2012-07-09 12:29:16 GMT
Hi guilers,
I've mentioned these to Mark Weaver on IRC off-hand before, but I'm
posting this bug report to "formalise" it, and make sure we don't
forget.
Peter Bex, as one of the maintainers of the chicken "numbers" egg,
created a thorough test suite for string->number a while ago[0], and it
points out a number of possible and actual errors in the handling of
string->number.
I've attached a copy with the modifications for guile already applied,
and a copy of the full results, but the summary is as follows.
If the number contains a division by zero, we get a numerical overflow
error.
scheme <at> (guile−user)> (string->number "3/0")
ERROR: In procedure string−>number:
ERROR: Throw to key `numerical−overflow' with args `("make−ratio" "Numerical overflow" #f #f)'.
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
scheme <at> (guile−user) [1]> ,q
This contradicts the r6rs specification[1], which mandates a return
value of #f. IMO, this is the correct behaviour, since otherwise, we
have created a special case in the API for one type of invalid number.
(These tests cause the program to stop, and so are commented out in the
(Continue reading)
RSS Feed