From 76e10351faa20301f73a333b13f94a41059baf14 Mon Sep 17 00:00:00 2001 From: ksss Date: Sun, 5 Mar 2017 14:15:18 +0900 Subject: String#index shouldn't return nil when "".index "" --- src/string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/string.c b/src/string.c index 9efc89b34..c36b7524a 100644 --- a/src/string.c +++ b/src/string.c @@ -1608,7 +1608,7 @@ mrb_str_index(mrb_state *mrb, mrb_value str) return mrb_nil_value(); } } - if (pos >= clen) return mrb_nil_value(); + if (pos > clen) return mrb_nil_value(); pos = chars2bytes(str, 0, pos); switch (mrb_type(sub)) { -- cgit v1.2.3