Issue #517 - Raise error when reading invalid number

Previously #f was returned in this case but it is more correct to raise an error instead. This prevents weird edge cases and is more consistent with other schemes.
This commit is contained in:
Justin Ethier 2023-12-05 18:14:52 -08:00
parent 6c04ce4ca4
commit 334787b6d6
2 changed files with 11 additions and 1 deletions

View file

@ -17,6 +17,7 @@ Bug Fixes
- Fix `read-line` to read entire lines that consist of more than 1022 bytes. Previously the function would only return partial data up to this limit. Thanks to Robby Zambito for the bug report.
- `(include "body.scm")` inside a file `path/to/lib.sld` will look for `path/to/body.scm`, then fallback to the legacy behavior, and look for `$(pwd)/body.scm`.
- Pass append and prepend directories when compiling dependent libraries of a program. This prevents issues where the directories are not made available to any `include` directives within such libraries.
- Updated the reader to throw an error if a number cannot be parsed, rather than returning `#f`.
## 0.35.0 - August 25, 2022

View file

@ -179,6 +179,12 @@
"(void *data, object ptr, object opq)"
" return(Cyc_is_string(opaque_ptr(opq)));")
(define-c Cyc-opaque->string
"(void *data, int argc, closure _, object k, object opq)"
" return_closcall1(data, k, opaque_ptr(opq));"
"(void *data, object ptr, object opq)"
" return(opaque_ptr(opq));")
(define-c Cyc-opaque-unsafe-string->number
"(void *data, int argc, closure _, object k, object opq)"
" Cyc_string2number_(data, k, opaque_ptr(opq));")
@ -226,7 +232,10 @@
((Cyc-opaque? token)
(cond
((Cyc-opaque-unsafe-string? token)
(Cyc-opaque-unsafe-string->number token))
(let ((rv (Cyc-opaque-unsafe-string->number token)))
(if rv
rv
(error "Invalid numeric syntax" (Cyc-opaque->string token)))))
;; Open paren, start read loop
((Cyc-opaque-unsafe-eq? token #\()
(let ((line-num (get-line-num fp))