Bug #1731

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

Added by runpaint (Run Paint Run Run) almost 3 years ago. Updated about 1 year ago.

[ruby-core:24150]
Status:Closed Start date:07/05/2009
Priority:Normal Due date:
Assignee:- % 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 (Nobuyoshi Nakada) almost 3 years ago

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

Revision 23967
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

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

Revision 24017
Added by nobu (Nobuyoshi Nakada) almost 3 years ago

* array.c (recursive_join): use obj to tell if recursion occurs. [ruby-core:24150] * enum.c (enum_join): reverted r23966. [ruby-core:24196]

History

Updated by runpaint (Run Paint Run Run) almost 3 years ago

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

Updated by runpaint (Run Paint Run Run) almost 3 years ago

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)".

Updated by nobu (Nobuyoshi Nakada) almost 3 years ago

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

Also available in: Atom PDF