Bug #1731 [ruby-core:24150]

Enumerable#join with Recursive Structure: "invalid inspect_tbl list for :to_a"

Added by Run Paint Run Run 256 days ago. Updated 256 days ago.

Status :Closed Start :07/05/2009
Priority :Normal Due date :
Assigned to :- % Done :

100%

Category :-
Target version :-
ruby -v :

ruby 1.9.2dev (2009-07-05 trunk 23958) [i686-linux]


Description

class Enum
      include Enumerable
      
      def initialize
        @elements = [self]
      end
      def each
        @elements.each {|e| yield e}
      end
    end
  
    Enum.new.join

This code hangs for a second or so then complains:

  $ ruby -vw /tmp/inspect_tbl.rb 
  ruby 1.9.2dev (2009-07-05 trunk 23958) [i686-linux]
  /tmp/inspect_tbl.rb:11:in `to_a': invalid inspect_tbl list for :to_a in #<Thread:0x990645c run> (TypeError)
	from /tmp/inspect_tbl.rb:11:in `join'
	from /tmp/inspect_tbl.rb:11:in `<main>'

Associated revisions

Revision 23966
Added by nobu 256 days ago

  • enum.c (enum_join): deals with self recursive objects to get rid of infinite recursion. [ruby-core:24150]

Revision 23967
Added by nobu 256 days ago

  • enum.c (enum_join): deals with self recursive objects to get rid of infinite recursion. [ruby-core:24150]

Revision 24017
Added by nobu 251 days ago

History

07/05/2009 11:41 PM - Run Paint Run Run

Drat. I filed this against the wrong version; it should be against trunk. :-(

07/06/2009 04:33 AM - Run Paint Run Run

Apologies if this is obvious, but I just noticed that if you rescue the aforementioned exception then say File.join(['a','b','c']), File will raise an exception "`join': recursive array (ArgumentError)".

07/06/2009 09:07 AM - Nobuyoshi Nakada

  • Status changed from Open to Closed
  • % Done changed from 0 to 100
Applied in changeset r23966.

Also available in: Atom PDF