GitHub

Original file line numberDiff line numberDiff line change

@@ -1858,11 +1858,18 @@ mrb_hash_to_s(mrb_state *mrb, mrb_value self)

18581858

struct RHash *h = mrb_hash_ptr(self);

18591859

H_EACH(h, entry) {

18601860

if (i++ > 0) mrb_str_cat_lit(mrb, ret, ", ");

1861-

H_CHECK_MODIFIED(mrb, h) {

1862-

mrb_str_cat_str(mrb, ret, mrb_inspect(mrb, entry->key));

1861+

if (mrb_symbol_p(entry->key)) {

1862+

mrb_str_cat_str(mrb, ret, mrb_obj_as_string(mrb, entry->key));

1863+

mrb_gc_arena_restore(mrb, ai);

1864+

mrb_str_cat_lit(mrb, ret, ": ");

1865+

}

1866+

else {

1867+

H_CHECK_MODIFIED(mrb, h) {

1868+

mrb_str_cat_str(mrb, ret, mrb_inspect(mrb, entry->key));

1869+

}

1870+

mrb_gc_arena_restore(mrb, ai);

1871+

mrb_str_cat_lit(mrb, ret, " => ");

18631872

}

1864-

mrb_gc_arena_restore(mrb, ai);

1865-

mrb_str_cat_lit(mrb, ret, " => ");

18661873

H_CHECK_MODIFIED(mrb, h) {

18671874

mrb_str_cat_str(mrb, ret, mrb_inspect(mrb, entry->val));

18681875

}

Read the original on github.com ↗