зеркало из https://github.com/golang/tools.git
internal/refactor/inline: don't treat blanks as decls in declares()
Plus, a test. Change-Id: I9d3f4729c1b8da51d771442d9c3f5909f608591e Reviewed-on: https://go-review.googlesource.com/c/tools/+/534895 Reviewed-by: Robert Findley <rfindley@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Alan Donovan <adonovan@google.com>
This commit is contained in:
Родитель
348453412b
Коммит
f85b3f7bcd
|
@ -2622,6 +2622,7 @@ func declares(stmts []ast.Stmt) map[string]bool {
|
|||
}
|
||||
}
|
||||
}
|
||||
delete(names, "_")
|
||||
return names
|
||||
}
|
||||
|
||||
|
|
|
@ -388,6 +388,17 @@ func TestBasics(t *testing.T) {
|
|||
`func _(ch chan int) { f(ch) }`,
|
||||
`func _(ch chan int) { <-(<-chan int)(ch) }`,
|
||||
},
|
||||
{
|
||||
// (a regression test for unnecessary braces)
|
||||
"In block elision, blank decls don't count when computing name conflicts.",
|
||||
`func f(x int) { var _ = x; var _ = 3 }`,
|
||||
`func _() { var _ = 1; f(2) }`,
|
||||
`func _() {
|
||||
var _ = 1
|
||||
var _ = 2
|
||||
var _ = 3
|
||||
}`,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче