Repository navigation
fix references and rename of loop labels - #3303
Open
jayhemnani9910 wants to merge 1 commit into
Open
jayhemnani9910 wants to merge 1 commit into
jayhemnani9910 wants to merge 1 commit into
Conversation
Loop labels could not be renamed from their declaration (also not on inline loops), and a break in the loop's else branch was left out, so renaming from the body broke the code.
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.
Renaming a
for/whilelabel has two problems:outer: for ...), references, rename and highlight return nothing. Block and switch labels work. Loop labels are declared in the loop body's scope, which starts after the label, andlabel: inline forwas not seen as a label declaration at all.break :labelin the loop'selsebranch is left out. Renaming from the body then leaves code that does not compile:lookupLabelnow falls back to the label declaration at the cursor,inlineafterlabel:is a label declaration, and label references scan to the end of the whole loop.Added cases to the
labelreferences test (for with else, while with continue expression and else, inline for) and to thelabel declposition context test; they fail before the change.zig build testpasses (582 passed, 11 skipped).