palkan/anyway_config

Random segfaults with Rails on Ruby 2.7

palkan opened this issue · 1 comments

See https://bugs.ruby-lang.org/issues/17382

Although that's definitely an MRI issue, we can fix it at our end.
The feature is used for pretty printing:

using(Module.new do
refine Hash do
def inspect
"{#{map { |k, v| "#{k}: #{v.inspect}" }.join(", ")}}"
end
end

We can either make it explicit or, maybe, using a unique name would work:

using(Module.new do
  refine Object do
     alias __pp__ inspect
  end
  
  refine Hash do
     def __pp__
       # ...
     end
  end
end)

And then call v.__pp__ for all the printed values.

Should be fixed in 2.3.0