summaryrefslogtreecommitdiffhomepage
path: root/src/string.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2014-12-17 20:08:26 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2014-12-17 20:08:26 +0900
commit4319eaaa45ce26e73cfac6e1c8b724e35680577b (patch)
treed7b084071134f78d9a5515e316faeea775581407 /src/string.c
parent05b00a14c5081ee4bf362b12839dcbb94df1169a (diff)
downloadmruby-4319eaaa45ce26e73cfac6e1c8b724e35680577b.tar.gz
mruby-4319eaaa45ce26e73cfac6e1c8b724e35680577b.zip
try to convert not only nil but every objects to fixnums; ref #2677
Diffstat (limited to 'src/string.c')
-rw-r--r--src/string.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/string.c b/src/string.c
index 2b1a27fee..aa26b261c 100644
--- a/src/string.c
+++ b/src/string.c
@@ -781,7 +781,10 @@ num_index:
}
}
default:
- if (mrb_nil_p(indx)) mrb_raise(mrb, E_TYPE_ERROR, "can't convert nil into Integer");
+ indx = mrb_Integer(mrb, indx);
+ if (mrb_nil_p(indx)) {
+ mrb_raise(mrb, E_TYPE_ERROR, "can't convert to Fixnum");
+ }
idx = mrb_fixnum(indx);
goto num_index;
}