-
-
Notifications
You must be signed in to change notification settings - Fork 96
Fix renaming in DrRacket #415
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
Conversation
It is possible to have an arrow between two identifiers that are not textually equivalent (definitely possible in DrRacket, and theoretically possible in Racket Mode). In the above event, renaming one identifier should not change the other. See also racket/drracket#415 for a similar fix in DrRacket, and racket/racket#3391 which would start to make Racket Mode behave incorrectly. In particular, with the above PR, renaming the identifier `a` in the following program should not rename `all-defined-out` as well. #lang racket (provide (all-defined-out)) (define a 1)
I am not sure about this -- I never thought that we should compare the characters in the original program! It seems like it might be that someone somewhere has a language that this would break if they, for example, equate variables with and without accents of them or ... who knows what else. Still, for the majority of things (everything I actually know about) this seems like a great idea! I'm not sure if it is necessary but we could add a backwards compatibility hedge in the form of a property that would say "rename even if the name is different" that could be plumbed through? And we probably do need some tests (this time I'm just not missing them am I?). |
CC: @greghendershott
That's a good point. One instance I can see is when
There are two problems at hand: (1) how can language + macro indicate when it's safe (or unsafe) to rename an identifier? (2) how can Check Syntax provide these information to clients (e.g., DrRacket, Racket Mode) in a backward-compatible manner? For (2), Racket Mode currently uses Racket Mode would implement both For (1), since currently there's no restriction, it seems to me that to make it backward compatible, it should be an opt-out mechanism. That is, all local connections would make
Yes, I will add tests. |
@rfindler: To prevent the PR from becoming massive, should I make a change to only include the uncontroversial part of the this PR (the first issue in the top post), and separate the rest (the second issue in the top post) as a separate PR? |
I'm not sure exactly what you have in mind with the split but I do agree with the general principle that getting uncontroversial improvements in their own PRs and merging them is Very Good. |
Well, I just want to make it easy for you to review. Do you have any comment about my above plan of adding |
Consider the program: #lang racket (require racket/list) Right clicking `require` will offer users to rename the `racket` identifier which doesn't make much sense. Users right click `require` because they want to rename that particular identifier, not others. This PR fixes the issues.
bf5a67f
to
a9b5f70
Compare
OK, I removed the "compare the characters in the original program" from the PR and added tests. All tests passed, so it's ready for a review (and merge). I will submit a separate, draft PR that implements Thanks! |
check that the symbolic name of a binder and its reference are the same Also, it appears that something changed along the way such that we no longer need the special case that solved issue #110 anymore
Renaming in DrRacket is currently broken in two ways.
Consider the program:
Right clicking
require
will offer users to rename theracket
identifier which doesn't make much sense. Users right click
require
because they want to rename that particular identifier, not others.
2. To continue from the above example, renaming `racket` to `racket/base` will cause all identifiers imported from `racket` to be renamed to `racket/base`. That is, it would result in:
This bug will become even more annoying after racket/racket#3391
is merged, since renaming any defined identifier will cause
all-defined-out
to be renamed as well.This PR fixes both issues. That is, renaming at a position will pick an
identifier from that position,
and renaming an identifier will onlycause identifiers that are textually equivalent to that identifier
to be renamed.