mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
fix: to_a integer ranges with begin > end failing
example of failure: ```rb (-1..-4).to_a ``` expected result: ```rb (-1..-4).to_a ```
This commit is contained in:
@@ -358,6 +358,10 @@ range_num_to_a(mrb_state *mrb, mrb_value range)
|
||||
if (mrb_integer_p(end)) {
|
||||
mrb_int a = mrb_integer(beg);
|
||||
mrb_int b = mrb_integer(end);
|
||||
|
||||
if (a > b) {
|
||||
return mrb_ary_new_capa(mrb, 0);
|
||||
}
|
||||
mrb_int len;
|
||||
|
||||
if (mrb_int_sub_overflow(b, a, &len)) {
|
||||
|
||||
Reference in New Issue
Block a user