Skip to content

Conversation

@laelath
Copy link

@laelath laelath commented Dec 22, 2025

Adds support for the upcoming become expressions for guaranteed tail recursion.

@wetneb
Copy link

wetneb commented Dec 22, 2025

Thanks for working on this, but this doesn't seem sufficient to me. I would expect changes to the grammar.js to make it possible to parse expressions involving the keyword. At least one test case (in test/corpus) should be provided.

@laelath
Copy link
Author

laelath commented Dec 23, 2025

That's an embarrassing mistake to have edited the auto-generated file instead of the actual source file. I fixed that and added some tests taken from the rust doc page on become. I made the choice to have the sub-expression be allowed to be any arbitrary expression, even though strictly speaking it only needs to accept call expressions, though I checked that the rustc parser also follows this behavior, rejecting non-call becomes at a later stage.

@wetneb
Copy link

wetneb commented Dec 23, 2025

Thanks a lot! It's not embarrassing at all, auto-generated files shouldn't be checked into Git in the first place, so it's not your fault…
The reasoning about enabling become for all expressions sounds good to me. It could be worth checking that "become" can still be used as a regular identifier (such as let become = 4 or pub fn become() {}), especially since this is an unstable feature.

By the way I'm not a maintainer here but I'll happily integrate your changes into the tree-sitter-rust-orchard fork.

@laelath
Copy link
Author

laelath commented Dec 23, 2025

I don't think those test cases are valid rust syntax, since while become is an unstable feature, it is a reserved keyword in current stable versions of rust.

Feel free to merge this into your fork!

@wetneb
Copy link

wetneb commented Dec 23, 2025

My bad, you are clearly right!
Then I'm porting and releasing this into https://codeberg.org/grammar-orchard/tree-sitter-rust-orchard.
Thank you!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants