Skip to content

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

@headius

Description

@headius

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions