tree-sitter / tree-sitter-rust

Rust grammar for tree-sitter
MIT License
337 stars 96 forks source link

bug: shebang does not require semicolon #226

Open matthiaskrgr opened 2 months ago

matthiaskrgr commented 2 months ago

Did you check existing issues?

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

No response

Describe the bug

FP parse error

Steps To Reproduce/Bad Parse Tree

(source_file (shebang) (expression_statement (binary_expression left: (identifier) right: (call_expression function: (identifier) (ERROR (identifier) (identifier)) arguments: (arguments))) (MISSING ";")) (expression_statement (block)))

[source_file](https://tree-sitter.github.io/tree-sitter/playground#) [0, 0] - [4, 0]
  [shebang](https://tree-sitter.github.io/tree-sitter/playground#) [0, 0] - [2, 3]
  [expression_statement](https://tree-sitter.github.io/tree-sitter/playground#) [2, 4] - [3, 9]
    [binary_expression](https://tree-sitter.github.io/tree-sitter/playground#) [2, 4] - [3, 9]
      left: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [2, 4] - [2, 9]
      right: [call_expression](https://tree-sitter.github.io/tree-sitter/playground#) [2, 10] - [3, 9]
        function: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [2, 10] - [2, 14]
        [ERROR](https://tree-sitter.github.io/tree-sitter/playground#) [3, 0] - [3, 7]
          [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [3, 0] - [3, 2]
          [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [3, 3] - [3, 7]
        arguments: [arguments](https://tree-sitter.github.io/tree-sitter/playground#) [3, 7] - [3, 9]
    [MISSING ;](https://tree-sitter.github.io/tree-sitter/playground#) [3, 9] - [3, 9]
  [expression_statement](https://tree-sitter.github.io/tree-sitter/playground#) [3, 10] - [3, 12]
    [block](https://tree-sitter.github.io/tree-sitter/playground#) [3, 10] - [3, 12]

Expected Behavior/Parse Tree

there does not need to be a ";" as rustc accepts the code

Repro

#!

//@ check-pass
fn main() {}