Commit daf64bf5 authored by Robert Griesemer's avatar Robert Griesemer

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
parent 5c4917ce
......@@ -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
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment