Ruby2Ruby incorrectly changes the behavior of the following input code:
defined?(NotDefined) ? 1 : 2 # => 1
The incorrect output is this:
defined? NotDefined ? 1 : 1 # => "expression"
While the omission of parentheses would be correct if defined? was a method, it is a keyword with a different precendence. With added parentheses the emitted code works like this:
defined?(NotDefined ? 1 : 1) # => "expression"
I believe this is an issue with ruby2ruby instead of ruby_parser, as the parsed AST looks correct:
sexp = RubyParser.new.process('defined?(Foo) ? 1 : 2')
=> s(:if, s(:defined, s(:const, :Foo)), s(:lit, 1), s(:lit, 2))