Skip to content

Add support for strings on the LHS of function definitions #147

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

Merged
merged 3 commits into from
May 30, 2025

Conversation

MichaelChirico
Copy link
Contributor

Closes #143

@MichaelChirico MichaelChirico marked this pull request as ready for review September 26, 2024 16:43
@MichaelChirico
Copy link
Contributor Author

I think the new tests are good & look like they're passing so my edits to tags.scm are WAI? My first time touching tree-sitter so please hand-hold if that's wrong 🙏

I think backticked names were already captured, but adding a test here since that's a useful edge case to keep tabs on.

I wonder if shorthand-lambdas should be included as well, but decided against it as out-of-scope for this PR for now, WDYT?

@MichaelChirico
Copy link
Contributor Author

Friendly ping! If you're swamped that's fine, just reminding before I forget about it myself :)

@DavisVaughan
Copy link
Member

I wonder if shorthand-lambdas should be included as well

This actually would be included because native anonymous functions are part of function_definition

fn <- \(x) x

@DavisVaughan
Copy link
Member

I was a little worried about this because capturing (string) captures the " or ' in the name too, and I was wondering how github would work with that.

But I'm remembering that we already capture backticks in the name for something like `fn` and that works fine due to github's good fuzzy search:

Screenshot 2025-05-30 at 2 28 45 PM

So I think just using (string) over (string_content) is fine, and you'll see "my_function" pop up in the github ui, but you'll still be able to nicely match against it with my_ IIUC. If we are wrong, this isn't hard to change in the future.

@DavisVaughan DavisVaughan merged commit 00ff395 into r-lib:main May 30, 2025
12 checks passed
@MichaelChirico MichaelChirico deleted the patch-1 branch May 30, 2025 18:41
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.

tags.scm should probably recognize functions with string names on the LHS
2 participants