Commit 97761502 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

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

Use mrb_ptr instead of mrb_cptr in Kernel#to_s
parents d89cfca0 9c61e1cd
......@@ -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;
......
......@@ -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
......
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