-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
RefactoringIssues related to refactoring toolsIssues related to refactoring toolsToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.
Milestone
Description
When extracting statements from the body of a loop that include continue
, but not the enclosing loop, gopls seems not to notice the implications of the continue statement, and this generates invalid code. Extracting:
func f(cond bool) {
for range "abc" {
| if cond {
| continue
| }
| println(0)
}
}
becomes:
func f(cond bool) {
for range "abc" {
newFunction1(cond)
}
}
func newFunction1(cond bool) {
if cond {
continue // error: continue not in loop
}
println(0)
}
This is a pity since the extract logic seems to go to great trouble to deal with return continuations.
Metadata
Metadata
Assignees
Labels
RefactoringIssues related to refactoring toolsIssues related to refactoring toolsToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.