Skip to content

bug: String concatenation using << and without spaces considers it as a heredoc #256

Description

@Bennet-Sunder

Did you check existing issues?

  • I have read all the tree-sitter docs if it relates to using the parser
  • I have searched the existing issues of tree-sitter-c

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

tree-sitter = "0.20.6", tree-sitter-ruby = "0.20.1"

Describe the bug

When using string concatenation without any spaces using << operator it looks like it is mistaking it for a heredoc string.

Steps To Reproduce/Bad Parse Tree

Using the ruby code

"test"<<"ruby"

Generates the following tree

program [0, 0] - [1, 0]
  string [0, 0] - [0, 6]
    string_content [0, 1] - [0, 5]
  MISSING ; [0, 6] - [0, 6]
  heredoc_beginning [0, 6] - [0, 14]
  heredoc_body [0, 14] - [1, 0]
    heredoc_content [0, 14] - [1, 0]
    heredoc_end [1, 0] - [1, 0]

Here the string followed by << is considered as a heredoc but this code evaluates to "testruby". When I add a space after the << I get the below tree which is what I'm looking for.

for code

"test"<< "ruby"

This is the tree

program [0, 0] - [1, 0]
binary [0, 0] - [0, 15]
    left: string [0, 0] - [0, 6]
    string_content [0, 1] - [0, 5]
    right: string [0, 9] - [0, 15]
    string_content [0, 10] - [0, 14]

Expected Behavior/Parse Tree

Tree with spaces

This is the tree

program [0, 0] - [1, 0]
binary [0, 0] - [0, 15]
    left: string [0, 0] - [0, 6]
    string_content [0, 1] - [0, 5]
    right: string [0, 9] - [0, 15]
    string_content [0, 10] - [0, 14]

Repro

No response

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions