1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 22:10:21 +02:00

Restrict intsets and maps to non-negative integers

* module/language/cps/intmap.scm (intmap-add):
* module/language/cps/intset.scm (intset-add): Restrict to only hold
  non-negative integers.
This commit is contained in:
Andy Wingo 2014-07-03 09:37:30 +02:00
parent e9808c14d7
commit 4296c36ec8
2 changed files with 6 additions and 0 deletions

View file

@ -121,6 +121,9 @@
(match bs
(($ <intmap> min shift root)
(cond
((< i 0)
;; The power-of-two spanning trick doesn't work across 0.
(error "Intmaps can only map non-negative integers." i))
((not val) (intmap-remove bs i))
((not root)
;; Add first element.

View file

@ -152,6 +152,9 @@
(match bs
(($ <intset> min shift root)
(cond
((< i 0)
;; The power-of-two spanning trick doesn't work across 0.
(error "Intsets can only hold non-negative integers." i))
((not root)
;; Add first element.
(let ((min (round-down i shift)))