From: richard.viney@... Date: 2017-01-22T01:57:16+00:00 Subject: [ruby-core:79211] [Ruby trunk Bug#13144] prettyprint doesn't detect cycles when wrapped inside Delegators Issue #13144 has been updated by Richard Viney. Pull request with my fix and new test case: https://github.com/ruby/ruby/pull/1518 ---------------------------------------- Bug #13144: prettyprint doesn't detect cycles when wrapped inside Delegators https://bugs.ruby-lang.org/issues/13144#change-62631 * Author: Richard Viney * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: 2.4.0 * Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN ---------------------------------------- The line count of the pretty print output for the following class grows factorially with the number of self-referencing SimpleDelegator instances created by the initializer. With an n of 8 the line count of the pretty print output is almost one million! This occurs because the cycle detection in lib/pp.rb doesn't detect the already printed object due to it being wrapped inside a Delegator instance. The same problem occurs with pretty printing cycles wrapped inside WeakRef because it is a subclass of Delegator. class Foo def initialize(n) n.times { |i| instance_variable_set "@a#{i}", SimpleDelegator.new(self) } end end -- https://bugs.ruby-lang.org/ Unsubscribe: