Skip to content

Add rename capability#127

Draft
tomatitito wants to merge 16 commits into
mainfrom
add-rename-capability
Draft

Add rename capability#127
tomatitito wants to merge 16 commits into
mainfrom
add-rename-capability

Conversation

@tomatitito
Copy link
Copy Markdown
Owner

@WardBrian This is still WIP, but I thought I'd push it anyway so you can observe what's going on. That way, you don't have to look at one big diff.

@tomatitito tomatitito marked this pull request as draft May 11, 2026 20:54
@WardBrian
Copy link
Copy Markdown
Collaborator

Just note that renaming in Stan is not trivial, due to overloading and shadowing.

functions {
 void foo(int x){} // 1
 void foo(real x){} // 2
}
generated quantities {
 foo(3.14); // 3
}

Renaming 1 should probably not change 3, but renaming two should. The easiest thing to do might just be rename all of 1,2 and 3 together, but that's not always what you wanted.

Similarly, you can have a variable and a function both named beta. So you have to know that when it's the first argument of map_rect, it's a function, but in other places, it's a parameter/etc.

@tomatitito
Copy link
Copy Markdown
Owner Author

Yes, I agree 100%! Since now we have a treesitter parser, we should be able to actually handle these things correctly. And we should have tests for cases like these. I'm sure you can come up with great tests, so when we are ready for it, it would be great if you could contribute!

@WardBrian
Copy link
Copy Markdown
Collaborator

I'm not positive tree-sitter alone will be enough, since some of those cases rely on how typing analysis is done, but it will certainly help

@tomatitito
Copy link
Copy Markdown
Owner Author

I see... ok, let's see what we can do here. Maybe we need to be more sophisticated.

@tomatitito tomatitito force-pushed the add-rename-capability branch from bb2ca02 to e5eda48 Compare May 14, 2026 21:14
@tomatitito
Copy link
Copy Markdown
Owner Author

@WardBrian It's not quite ready, but it's getting there. Take a look if you find some time. There are still some cases for which renaming doesn't work, and it only works for the file you are in. I'm positive that we are going to get this sorted out.

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