From 62382a434561b6fe56d479b8800cf6ccf017463c Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Thu, 30 Nov 2023 17:04:39 +0100 Subject: [PATCH] [ruby/pp] Use .class.members for pretty printing Data * Data#members might not be defined, instead it might be defined on Data subclasses or a module included there. This is notably the case on TruffleRuby which defines it there for optimization purposes. In fact the mere presence of Data#members implies a megamorphic call inside, so it seems best to avoid relying on its existence. https://github.com/ruby/pp/commit/6a97d36fbb --- lib/pp.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pp.rb b/lib/pp.rb index 7c4ba0e672..5e5fd06cae 100644 --- a/lib/pp.rb +++ b/lib/pp.rb @@ -423,7 +423,7 @@ end class Data # :nodoc: def pretty_print(q) # :nodoc: q.group(1, sprintf("#') { - q.seplist(PP.mcall(self, Data, :members), lambda { q.text "," }) {|member| + q.seplist(PP.mcall(self, Kernel, :class).members, lambda { q.text "," }) {|member| q.breakable q.text member.to_s q.text '='