Merge pull request #3317 from bouk/missing-to-s

Use mrb_ptr instead of mrb_cptr in Kernel#to_s
This commit is contained in:
Yukihiro "Matz" Matsumoto
2016-12-03 12:01:43 +09:00
committed by GitHub
2 changed files with 16 additions and 1 deletions
+1 -1
View File
@@ -444,7 +444,7 @@ mrb_any_to_s(mrb_state *mrb, mrb_value obj)
mrb_str_cat_lit(mrb, str, "#<");
mrb_str_cat_cstr(mrb, str, cname);
mrb_str_cat_lit(mrb, str, ":");
mrb_str_concat(mrb, str, mrb_ptr_to_str(mrb, mrb_cptr(obj)));
mrb_str_concat(mrb, str, mrb_ptr_to_str(mrb, mrb_ptr(obj)));
mrb_str_cat_lit(mrb, str, ">");
return str;
+15
View File
@@ -520,6 +520,21 @@ assert('Kernel#to_s', '15.3.1.3.46') do
assert_equal to_s.class, String
end
assert('Kernel#to_s on primitives') do
begin
Fixnum.alias_method :to_s_, :to_s
Fixnum.remove_method :to_s
assert_nothing_raised do
# segfaults if mrb_cptr is used
1.to_s
end
ensure
Fixnum.alias_method :to_s, :to_s_
Fixnum.remove_method :to_s_
end
end
assert('Kernel.local_variables', '15.3.1.2.7') do
a, b = 0, 1
a += b