+
Skip to content

parsing breaks on multi-line strings #54

@RichMorin

Description

@RichMorin

This gem is breaking for me when I try to parse a multi-line string. For example:

irb(main):020:0> text = <<EOT
irb(main):021:0" [foo]
irb(main):022:0" 
irb(main):023:0"   bar = '''
irb(main):024:0" baz
irb(main):025:0" '''
irb(main):026:0" EOT
=> "[foo]\n\n  bar = '''\nbaz\n'''\n"
irb(main):027:0> TOML.load(text)
NoMethodError: undefined method `ascii_tree' for nil:NilClass
from /Library/Ruby/Gems/2.3.0/gems/toml-0.2.0/lib/toml/parser.rb:12:in
      `rescue in initialize'
from /Library/Ruby/Gems/2.3.0/gems/toml-0.2.0/lib/toml/parser.rb:9:in `initialize'
from /Library/Ruby/Gems/2.3.0/gems/toml-0.2.0/lib/toml.rb:19:in `new'
from /Library/Ruby/Gems/2.3.0/gems/toml-0.2.0/lib/toml.rb:19:in `load'
from (irb):27
from /usr/bin/irb:11:in `<main>'

The problem occurs with either ''' or """ strings and with both load and load_file.
Here is some environment info:

$ gem list | grep toml
toml (0.2.0)
$ ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin17]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载