Skip to content

Instantly share code, notes, and snippets.

@mbj
Created January 6, 2014 15:22
Show Gist options
  • Save mbj/8284308 to your computer and use it in GitHub Desktop.
Save mbj/8284308 to your computer and use it in GitHub Desktop.
ruby returns take blocks?
mbj@mbj ~/devel/unparser (master*) % bundle exec ruby-parse return-a.rb return-b.rb
Using Parser::Ruby21 to parse 2 files.
(block
(return
(send nil :foo
(send nil :arg)))
(args
(arg :bar)) nil)
(return
(block
(send nil :foo
(send nil :arg))
(args
(arg :bar)) nil))
return foo arg do |bar|
end
return foo(arg) do |bar|
end
@mbj
Copy link
Author

mbj commented Jan 6, 2014

I expect both are parsed like return-b.rb.

@mbj
Copy link
Author

mbj commented Jan 6, 2014

In contrast RBX:

mbj@mbj ~/devel/unparser (master*) % ruby compile -S return-a.rb return-b.rb 
[:script,
 [:return,
  [:iter,
   [:call,
    nil,
    :foo,
    [:arglist, [:call, nil, :arg, nil], [:iter, [:args, :bar], [:nil]]]],
   [:args, :bar],
   [:nil]]]]
[:script,
 [:return,
  [:iter,
   [:call,
    nil,
    :foo,
    [:arglist, [:call, nil, :arg, nil], [:iter, [:args, :bar], [:nil]]]],
   [:args, :bar],
   [:nil]]]]

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