JoshCheek / seeing_is_believing

Displays the results of every line of code in your file
1.3k stars 54 forks source link

Blows up when the result of `inspect` has a singleton class #118

Closed JoshCheek closed 6 years ago

JoshCheek commented 6 years ago

The code that identified the problem:

class <<
  o_O = "O_o"
  def O_o o_O
    @_o = o_O
  end
  def inspect o_O = @_o
    o_O
    "lo(#{o_O})l"
    o_O.dup
  end
end

o_O :: O_o (o_O) # => TypeError: singleton can't be dumped

# ~> TypeError
# ~> singleton can't be dumped
# ~>
# ~> /Users/xjxc322/.gem/ruby/2.4.1/gems/seeing_is_believing-3.2.0/lib/seeing_is_believing/event_stream/producer.rb:116:in `dump'
# ~> /Users/xjxc322/.gem/ruby/2.4.1/gems/seeing_is_believing-3.2.0/lib/seeing_is_believing/event_stream/producer.rb:116:in `to_string_token'
# ~> /Users/xjxc322/.gem/ruby/2.4.1/gems/seeing_is_believing-3.2.0/lib/seeing_is_believing/event_stream/producer.rb:65:in `record_result'
# ~> /var/folders/yj/23xw_th91pl6xkdnyc733r01t48gqj/T/seeing_is_believing_temp_dir20171001-54301-1azfl6y/program.rb:14:in `<main>'

The reason why:

string = "test"

Marshal.dump string # => "\x04\bI\"\ttest\x06:\x06ET"

def string.wat() end
Marshal.dump string # => TypeError: singleton can't be dumped

# ~> TypeError
# ~> singleton can't be dumped
# ~>
# ~> /var/folders/yj/23xw_th91pl6xkdnyc733r01t48gqj/T/seeing_is_believing_temp_dir20171001-54636-luhe5r/program.rb:5:in `dump'
# ~> /var/folders/yj/23xw_th91pl6xkdnyc733r01t48gqj/T/seeing_is_believing_temp_dir20171001-54636-luhe5r/program.rb:5:in `<main>'