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

Psych has some issue with some inline objects. #24

aselder opened this Issue Aug 17, 2011 · 1 comment


2 participants

aselder commented Aug 17, 2011

This was discovered while I was playing around with roodi:

This YAML fragment parses fine under both Syck and Psych:

  pattern: !ruby/regexp /^[A-Z][a-zA-Z0-9]*$/

However, if you turn this into a single line object

ClassNameCheck:                  { pattern: !ruby/regexp /^[A-Z][a-zA-Z0-9]*$/ }

Psych blows up on it, although Syck handles it fine.

Psych::SyntaxError: couldn't parse YAML at line 4 column 60
from /Users/andrew/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:148:in `parse'
from /Users/andrew/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:148:in `parse_stream'
from /Users/andrew/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:119:in `parse'
from /Users/andrew/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:106:in `load'
from /Users/andrew/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:205:in `load_file'
from (irb):8
from /Users/andrew/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in `<main>'

tenderlove commented Dec 15, 2011

The problem is that when you put the regular expression inside a flow map node, the [] become ambiguous. In that context they could possibly be parsed as inline "flow arrays".

Hopefully this page will explain.

@tenderlove tenderlove closed this Dec 15, 2011

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