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

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

Open
2 tasks done
Bennet-Sunder opened this issue May 14, 2024 · 0 comments
Open
2 tasks done
Labels

Comments

@Bennet-Sunder
Copy link

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

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

No branches or pull requests

1 participant