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

bugfix: don't consider shortening variables with use statements #5465

Merged
merged 2 commits into from
Nov 26, 2024

Conversation

mitchellwrosen
Copy link
Member

Overview

Fixes #5464

There was a bug in the logic that considers when/where to place use statements that was causing occasional misprinting of code. This PR fixes the bug and adds a regression test.

Implementation notes

Removed line of code that treated variables as targets for use-statement insertion.

For example, we'd previously consider shortening a variable foo.bar.baz to bar.baz (via a use foo bar.baz) or baz (via a use foo.bar baz). Now, we'll leave variables like foo.bar.baz alone.

There may be an even smarter fix that safely inserts use to shorten variable names... but perhaps that could be implemented separately from the immediate bugfix. I also think it's probably fine to restrict use to shortening names for external references, not local variables (as this PR implements).

Test coverage

Transcript added, failing in first commit

@mitchellwrosen mitchellwrosen marked this pull request as ready for review November 25, 2024 19:52
@aryairani aryairani merged commit 612756d into trunk Nov 26, 2024
32 checks passed
@aryairani aryairani deleted the fix-count-uses-bug branch November 26, 2024 17:04
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.

use statements can sometimes erroneously capture local variables
2 participants