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 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
@headius headius added this to the JRuby 9.1.0.0 milestone Dec 28, 2015
headius added a commit that referenced this issue Dec 28, 2015
@enebo
Copy link
Member

@enebo enebo commented Dec 28, 2015

This also works if the call itself contains parens:

jruby -e '"a".sub!("b") do end&.foo 1'
enebo added a commit that referenced this issue Dec 28, 2015
@enebo enebo closed this Dec 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.