Repository navigation
Preserve initializer behavior when removing inlined variables - #903
Open
yangfan-yf-yf wants to merge 2 commits into
Open
yangfan-yf-yf wants to merge 2 commits into
yangfan-yf-yf wants to merge 2 commits into
Conversation
Check initializer names, annotations, and remaining reads before removing an inlined variable definition. Keep supported literal and bound-name deletions and preserve definitions when removal is disabled or excluded. Add execution regressions for refusal and successful inlining cases.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #903 +/- ##
==========================================
+ Coverage 95.34% 95.36% +0.02%
==========================================
Files 134 135 +1
Lines 26762 27012 +250
==========================================
+ Hits 25516 25761 +245
- Misses 1246 1251 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Check builtin, parameter, function, and imported aliases through changed source and execution, preserve outer bindings across unrelated literals, and verify atomic refusal for class-scope name initializers.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Inlining a variable with
remove=Truecan erase behavior at its definition, even when there is no executed read of the variable. For example, removingtarget = missingchanges a caughtNameErrorinto successful execution of the following statements. A syntactic read underif Falsedoes not prevent this change. Deleting an annotated definition can also discard its annotation and the effects observed when annotations are evaluated.I check these cases before producing changes. I refuse to remove a definition when its initializer name cannot be shown to be bound, when a module or class annotation would be discarded, or when a reference remains outside the selected
resourcesoronly_currentoccurrence. Without reads, I allow supported literal initializers and names whose existing binding is established. Ordinary cases such asvalue = 42; target = value; print(target)remain supported, including the corresponding unused bound-name deletion.remove=Falsekeeps the definition while selected reads are inlined. Selecting only a consumer also keeps the provider definition. Function-local name annotations, which are not evaluated, continue to allow removal with a supported initializer. I added execution regressions that check both output and actual source changes, plus atomic refusal cases that leave all files unchanged.This change is limited to definition removal in
InlineVariable. It shares the entry point with #894 and #897, but does not include their annotation-reference or lambda-binding changes and does not require either PR. It does not establish general equivalence for moving arbitrary expressions to their reads.Validation: