tree-sitter / tree-sitter-ruby

Ruby grammar for tree-sitter
MIT License
182 stars 58 forks source link

(heredoc_end) matches the EOF mark #182

Open stsewd opened 3 years ago

stsewd commented 3 years ago
def run
  a = <<~E
end

This file generates the following tree

program [0, 0] - [3, 0]
  method [0, 0] - [3, 0]
    name: identifier [0, 4] - [0, 7]
    assignment [1, 2] - [1, 10]
      left: identifier [1, 2] - [1, 3]
      right: heredoc_beginning [1, 6] - [1, 10]
    heredoc_body [1, 10] - [3, 0]
      heredoc_content [1, 10] - [3, 0]
      heredoc_end [3, 0] - [3, 0]
    MISSING end [3, 0] - [3, 0]

I know this isn't a completely valid file, but it would be nice to not generate a token for the EOF mark ((3, 0) position). This is causing several bugs on neovim https://github.com/nvim-treesitter/nvim-treesitter/issues/1531, we are making our code to check for cases like this so feel free to close this if you think is fine generating tokens like this for an incomplete file.