Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Objects with cyclic references #19

CvX opened this Issue Jun 20, 2011 · 1 comment


3 participants

CvX commented Jun 20, 2011

Hi. There seems to be an error regarding reading objects that have cyclic references. They are dumped as expected (required yaml anchors are in place) but on load they are omitted (resulting in nil). Syck on 1.8.7 is handling this case correctly.

Psych from master branch, using ruby-1.9.2-head ruby 1.9.2p274 (2011-06-06 revision 31932) [x86_64-darwin10.7.0] although it's also failing on stable 1.9.2

Here's a failing test case:

diff --git a/test/psych/test_object.rb b/test/psych/test_object.rb
index 9890d50..10665c7 100644
--- a/test/psych/test_object.rb
+++ b/test/psych/test_object.rb
@@ -11,6 +11,14 @@ module Psych

+  class Foo
+    attr_accessor :parent
+    def initialize(parent)
+      @parent = parent
+    end
+  end
   class TestObject < TestCase
     def test_dump_with_tag
       tag = Tagged.new
@@ -23,5 +31,12 @@ module Psych
       assert_equal tag.baz, tag2.baz
       assert_instance_of(Tagged, tag2)
+    def test_cyclic_references
+      tag = Tagged.new
+      foo = Foo.new(tag)
+      tag.baz = foo
+      assert_cycle(tag)
+    end

rsutphin commented Aug 16, 2011

I'm still seeing this issue in 1.9.2-p290 and 1.9.2-head (ruby 1.9.2p312 (2011-08-11 revision 32926) [x86_64-darwin10.8.0]). What's the appropriate place to request that ruby be updated with this fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment