From b293cebe662de083d0925f0238b7a81a35b9eb3c Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 29 Aug 2021 07:36:13 -0700 Subject: seq_iter: allow mixed fixnum/bignum ranges. * lib.c (seq_iter_init_with_info): The to value in a range could be a bignum, which we should treat as a bignum range, rather than blowing up due to calling c_num on that value. --- lib.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/lib.c b/lib.c index af9a9703..796853ec 100644 --- a/lib.c +++ b/lib.c @@ -943,9 +943,15 @@ void seq_iter_init_with_info(val self, seq_iter_t *it, if (less(rf, rt)) switch (type(rf)) { case NUM: - it->ui.cn = c_num(rf, self); - it->ul.cbound = c_num(rt, self); - it->ops = &si_range_cnum_ops; + if (bignump(rt) && !mp_in_intptr_range(mp(rt))) { + it->ui.vn = rf; + it->ul.vbound = rt; + it->ops = &si_range_bignum_ops; + } else { + it->ui.cn = c_num(rf, self); + it->ul.cbound = c_num(rt, self); + it->ops = &si_range_cnum_ops; + } break; case CHR: it->ui.cn = c_chr(rf); @@ -970,9 +976,15 @@ void seq_iter_init_with_info(val self, seq_iter_t *it, unsup_obj(self, it->inf.obj); } else if (!equal(rf, rt)) switch (type(rf)) { case NUM: - it->ui.cn = c_num(rf, self); - it->ul.cbound = c_num(rt, self); - it->ops = &si_rev_range_cnum_ops; + if (bignump(rt) && !mp_in_intptr_range(mp(rt))) { + it->ui.vn = rf; + it->ul.vbound = rt; + it->ops = &si_rev_range_bignum_ops; + } else { + it->ui.cn = c_num(rf, self); + it->ul.cbound = c_num(rt, self); + it->ops = &si_rev_range_cnum_ops; + } break; case CHR: it->ui.cn = c_chr(rf); -- cgit v1.2.3