diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d7f90ed..94631df1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Bug Fixes +- Raise an error if `odd?` or `even?` is passed a decimal number. Thanks to jpellegrini for the bug report. - 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. diff --git a/scheme/base.sld b/scheme/base.sld index ecae30da..c7747a2f 100644 --- a/scheme/base.sld +++ b/scheme/base.sld @@ -1409,8 +1409,14 @@ (if (< b 0) (if (<= res 0) res (+ res b)) (if (>= res 0) res (+ res b))))) - (define (odd? num) (= (modulo num 2) 1)) - (define (even? num) (= (modulo num 2) 0)) + (define (odd? num) + (if (integer? num) + (= (modulo num 2) 1) + (error "Not an integer" num))) + (define (even? num) + (if (integer? num) + (= (modulo num 2) 0) + (error "Not an integer" num))) (define-c bignum? "(void *data, int argc, closure _, object k, object obj)" " return_closcall1(data, k, Cyc_is_bignum(obj)); ")