]> Cypherpunks repositories - gostls13.git/commit
cmd/gofmt: fix normalization of imaginary number literals
authorRobert Griesemer <gri@golang.org>
Fri, 21 Jun 2019 16:06:56 +0000 (09:06 -0700)
committerRobert Griesemer <gri@golang.org>
Fri, 21 Jun 2019 17:24:29 +0000 (17:24 +0000)
commit41b9e99d5bfbea795a53fa260ef2c8c1cb8bdb3e
treea86ee89196f967e58535ff71d6df6e0c906bba5d
parent3f1422c799edb143303c86c0e875d44c3612df64
cmd/gofmt: fix normalization of imaginary number literals

The old code only normalized decimal integer imaginary number
literals. But with the generalized imaginary number syntax,
the number value may be decimal, binary, octal, or hexadecimal,
integer or floating-point.

The new code only looks at the number pattern. Only for decimal
integer imaginary literals do we need to strip leading zeroes.
The remaining normalization code simply ignore the 'i' suffix.
As a result, the new code is both simpler and shorter.

Fixes #32718.

Change-Id: If43fc962a48ed62002e65d5c81fddbb9bd283984
Reviewed-on: https://go-review.googlesource.com/c/go/+/183378
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/gofmt/gofmt.go
src/cmd/gofmt/testdata/go2numbers.golden
src/cmd/gofmt/testdata/go2numbers.input
src/math/cmplx/cmath_test.go