Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.3] Parser does not recognize lonely operator after do...end #3567

Closed
headius opened this issue Dec 28, 2015 · 1 comment
Closed

[2.3] Parser does not recognize lonely operator after do...end #3567

headius opened this issue Dec 28, 2015 · 1 comment

Comments

@headius
Copy link
Member

headius commented Dec 28, 2015

Simple enough example, from test/mri/ruby/test_call.rb's test_safe_call_block_*:

[] ~/projects/jruby $ ast -e '"a".sub! "b" do end&.foo 1'
AST:
RootNode 0
  CallNode:foo 0
    CallNode:sub! 0
      StrNode 0
      ArrayNode 0
        StrNode 0
      IterNode 0
        ArgsNode 0
          ListNode 0
          ListNode 0
          ListNode 0
          ListNode 0
    ArrayNode 0
      FixnumNode 0
, null

Note that the curly form does get recognized as a lazy call:

[] ~/projects/jruby $ ast -e '"a".sub!("b"){}&.foo 1'
AST:
RootNode 0
  CallNode[lazy]:foo 0
    CallNode:sub! 0
      StrNode 0
      ArrayNode 0
        StrNode 0
      IterNode 0
        ArgsNode 0
          ListNode 0
          ListNode 0
          ListNode 0
          ListNode 0
    ArrayNode 0
      FixnumNode 0
, null
@enebo
Copy link
Member

enebo commented Dec 28, 2015

This also works if the call itself contains parens:

jruby -e '"a".sub!("b") do end&.foo 1'

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

No branches or pull requests

2 participants