Commit 545c5eec authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge branch 'h2so5-string-nil-index'

parents 5b203ead 4319eaaa
...@@ -781,6 +781,10 @@ num_index: ...@@ -781,6 +781,10 @@ num_index:
} }
} }
default: default:
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); idx = mrb_fixnum(indx);
goto num_index; goto num_index;
} }
......
...@@ -72,6 +72,10 @@ assert('String#[]', '15.2.10.5.6') do ...@@ -72,6 +72,10 @@ assert('String#[]', '15.2.10.5.6') do
assert_equal 'bc', e1 assert_equal 'bc', e1
assert_equal 'bc', a3 assert_equal 'bc', a3
assert_nil b3 assert_nil b3
assert_raise(TypeError) do
a[nil]
end
end end
assert('String#[] with Range') do assert('String#[] with Range') do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment