summaryrefslogtreecommitdiffhomepage
path: root/src/array.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-03-19 20:59:30 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-03-19 20:59:30 +0900
commit09574922a987aaa0813a4dfd37ac89ca60ca4281 (patch)
tree8075d0a6a36dfd27a0cfb1f94ad934919545d8f6 /src/array.c
parent527dcd52478567c30547d10c87c867cc01865a82 (diff)
downloadmruby-09574922a987aaa0813a4dfd37ac89ca60ca4281.tar.gz
mruby-09574922a987aaa0813a4dfd37ac89ca60ca4281.zip
Should not check/call `to_str` for immediate objects; ref #3515
Diffstat (limited to 'src/array.c')
-rw-r--r--src/array.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/array.c b/src/array.c
index e3381e213..6fb7f1384 100644
--- a/src/array.c
+++ b/src/array.c
@@ -1048,15 +1048,17 @@ join_ary(mrb_state *mrb, mrb_value ary, mrb_value sep, mrb_value list)
break;
default:
- tmp = mrb_check_string_type(mrb, val);
- if (!mrb_nil_p(tmp)) {
- val = tmp;
- goto str_join;
- }
- tmp = mrb_check_convert_type(mrb, val, MRB_TT_ARRAY, "Array", "to_ary");
- if (!mrb_nil_p(tmp)) {
- val = tmp;
- goto ary_join;
+ if (!mrb_immediate_p(val)) {
+ tmp = mrb_check_string_type(mrb, val);
+ if (!mrb_nil_p(tmp)) {
+ val = tmp;
+ goto str_join;
+ }
+ tmp = mrb_check_convert_type(mrb, val, MRB_TT_ARRAY, "Array", "to_ary");
+ if (!mrb_nil_p(tmp)) {
+ val = tmp;
+ goto ary_join;
+ }
}
val = mrb_obj_as_string(mrb, val);
goto str_join;