mirror of
https://github.com/golang/go
synced 2024-11-22 03:14:41 -07:00
gofmt: don't substitute invalid positions with valid ones in rewrites
Fixes rewrite bug: 'f(x) -> f(0)' where functions "picked up" ... arguments. R=rsc CC=golang-dev https://golang.org/cl/2279041
This commit is contained in:
parent
5c4917ce33
commit
daf64bf567
@ -203,6 +203,10 @@ func subst(m map[string]reflect.Value, pattern reflect.Value, pos reflect.Value)
|
||||
}
|
||||
|
||||
if pos != nil && pattern.Type() == positionType {
|
||||
// use new position only if old position was valid in the first place
|
||||
if old := pattern.Interface().(token.Position); !old.IsValid() {
|
||||
return pattern
|
||||
}
|
||||
return pos
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user