Issue #501 - odd/even must receive an integer

Raise an error if a decimal number is passed to these primitives.
This commit is contained in:
Justin Ethier 2023-03-03 16:08:12 -08:00
parent bde930a18b
commit cb67aeb0a3
2 changed files with 9 additions and 2 deletions

View file

@ -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.

View file

@ -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)); ")