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: impl trait bound starting with a lifetime misparsed #234

Open
2 tasks done
AlexCid opened this issue Sep 5, 2024 · 0 comments
Open
2 tasks done

bug: impl trait bound starting with a lifetime misparsed #234

AlexCid opened this issue Sep 5, 2024 · 0 comments
Labels

Comments

@AlexCid
Copy link

AlexCid commented Sep 5, 2024

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-rust

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

No response

Describe the bug

impl trait claused that start with a lifetime are misparsed and produce an error token. The corresponding where clauses are parsed just fine

Steps To Reproduce/Bad Parse Tree

Try to parse the following code :

fn foo<'a>(x: impl 'a + Clone ) {}

You obtain the following parse-tree :

source_file [0, 0] - [1, 0]
  function_item [0, 0] - [0, 33]
    name: identifier [0, 3] - [0, 6]
    type_parameters: type_parameters [0, 6] - [0, 10]
      lifetime [0, 7] - [0, 9]
        identifier [0, 8] - [0, 9]
    parameters: parameters [0, 10] - [0, 30]
      parameter [0, 11] - [0, 29]
        pattern: identifier [0, 11] - [0, 12]
        type: bounded_type [0, 14] - [0, 29]
          abstract_type [0, 14] - [0, 21]
            ERROR [0, 19] - [0, 20]
            trait: type_identifier [0, 20] - [0, 21]
          type_identifier [0, 24] - [0, 29]
    body: block [0, 31] - [0, 33]

Expected Behavior/Parse Tree

Not sure what exact parse tree should be produced. It seems to me that the rule for abstract_type is wrong as it seems to support only one type.

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