seattlerb/ruby2ruby

RuntimeError: unknown arg type :masgn

troessner opened this issue · 2 comments

Hey guys,

I am not 100% sure if this is a bug in ruby2ruby, but on first glance it seems like it. The following code:

  require 'ruby2ruby'
  require 'ruby_parser'

  ruby =  %q!{ foo: :bar, omg: :wtf }.collect { |(key,value)| "#{key}=#{value}" }.join(' ')!
  parser    = RubyParser.new
  ruby2ruby = Ruby2Ruby.new
  sexp      = parser.process(ruby)

  ruby2ruby.process(sexp)

gives me:

RuntimeError: unknown arg type :masgn
    from /home/troessner/.rvm/gems/ruby-1.9.3-p286/gems/ruby2ruby-2.0.6/lib/ruby2ruby.rb:104:in `process_args'
    from /home/troessner/.rvm/gems/ruby-1.9.3-p286/gems/sexp_processor-4.3.0/lib/sexp_processor.rb:218:in `block (2 levels) in process'
    from /home/troessner/.rvm/gems/ruby-1.9.3-p286/gems/sexp_processor-4.3.0/lib/sexp_processor.rb:275:in `error_handler'
    from /home/troessner/.rvm/gems/ruby-1.9.3-p286/gems/sexp_processor-4.3.0/lib/sexp_processor.rb:217:in `block in process'
    from /home/troessner/.rvm/gems/ruby-1.9.3-p286/gems/sexp_processor-4.3.0/lib/sexp_processor.rb:340:in `in_context'
    from /home/troessner/.rvm/gems/ruby-1.9.3-p286/gems/sexp_processor-4.3.0/lib/sexp_processor.rb:194:in `process'
    from /home/troessner/.rvm/gems/ruby-1.9.3-p286/gems/ruby2ruby-2.0.6/lib/ruby2ruby.rb:537:in `process_iter'
    from /home/troessner/.rvm/gems/ruby-1.9.3-p286/gems/sexp_processor-4.3.0/lib/sexp_processor.rb:218:in `block (2 levels) in process'
    from /home/troessner/.rvm/gems/ruby-1.9.3-p286/gems/sexp_processor-4.3.0/lib/sexp_processor.rb:275:in `error_handler'
    from /home/troessner/.rvm/gems/ruby-1.9.3-p286/gems/sexp_processor-4.3.0/lib/sexp_processor.rb:217:in `block in process'
    from /home/troessner/.rvm/gems/ruby-1.9.3-p286/gems/sexp_processor-4.3.0/lib/sexp_processor.rb:340:in `in_context'
    from /home/troessner/.rvm/gems/ruby-1.9.3-p286/gems/sexp_processor-4.3.0/lib/sexp_processor.rb:194:in `process'
    from /home/troessner/.rvm/gems/ruby-1.9.3-p286/gems/ruby2ruby-2.0.6/lib/ruby2ruby.rb:194:in `process_call'
    from /home/troessner/.rvm/gems/ruby-1.9.3-p286/gems/sexp_processor-4.3.0/lib/sexp_processor.rb:218:in `block (2 levels) in process'
    from /home/troessner/.rvm/gems/ruby-1.9.3-p286/gems/sexp_processor-4.3.0/lib/sexp_processor.rb:275:in `error_handler'
    from /home/troessner/.rvm/gems/ruby-1.9.3-p286/gems/sexp_processor-4.3.0/lib/sexp_processor.rb:217:in `block in process'
    from /home/troessner/.rvm/gems/ruby-1.9.3-p286/gems/sexp_processor-4.3.0/lib/sexp_processor.rb:340:in `in_context'
    from /home/troessner/.rvm/gems/ruby-1.9.3-p286/gems/sexp_processor-4.3.0/lib/sexp_processor.rb:194:in `process'

Any idea what's going on here?

Yeah. looks like a bug in r2r. Prolly from the changes in ruby_parser to make blocks look/feel like a combination of calls and defns. The masgn (eg |(key,value)|) is tripping it up because it doesn't know what to do. Should be easy enough to reduce to a test case and then fix. Thanks for the report.

OK. I finally got around to reworking the tests and redid process_masgn from scratch for this. Thanks for reporting.