diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f270f22..4ec00b84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/scheme/read.sld b/scheme/read.sld index efc41e21..0b67f6e4 100644 --- a/scheme/read.sld +++ b/scheme/read.sld @@ -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))