summaryrefslogtreecommitdiff
path: root/enumerator.c
diff options
context:
space:
mode:
Diffstat (limited to 'enumerator.c')
-rw-r--r--enumerator.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/enumerator.c b/enumerator.c
index d7546ee9e8..2c9858cda6 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -3802,6 +3802,13 @@ rb_arithmetic_sequence_beg_len_step(VALUE obj, long *begp, long *lenp, long *ste
*stepp = step;
if (step < 0) {
+ if (aseq.exclude_end && !NIL_P(aseq.end)) {
+ /* Handle exclusion before range reversal */
+ aseq.end = LONG2NUM(NUM2LONG(aseq.end) + 1);
+
+ /* Don't exclude the previous beginning */
+ aseq.exclude_end = 0;
+ }
VALUE tmp = aseq.begin;
aseq.begin = aseq.end;
aseq.end = tmp;