]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: normalize more whitespace in rewrite rules
authorJosh Bleecher Snyder <josharian@gmail.com>
Sun, 10 Mar 2019 03:34:58 +0000 (19:34 -0800)
committerJosh Bleecher Snyder <josharian@gmail.com>
Mon, 11 Mar 2019 17:18:40 +0000 (17:18 +0000)
If you write a rewrite rule:

(something) && noteRule("X")-> (something)

then rulegen will panic with an error message about commutativity.
The real problem is the lack of a space between the ) and the ->.
Normalize that bit of whitespace too.

Change-Id: Idbd53687cd0398fe275ff2702667688cad05b4ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/166427
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/ssa/gen/rulegen.go

index 730e768ed64dc2bc92d97fe632ff59780907d7ed..f3a54b629975f8d173994b1d24788d851293a467 100644 (file)
@@ -1019,5 +1019,6 @@ func normalizeWhitespace(x string) string {
        x = strings.Join(strings.Fields(x), " ")
        x = strings.Replace(x, "( ", "(", -1)
        x = strings.Replace(x, " )", ")", -1)
+       x = strings.Replace(x, ")->", ") ->", -1)
        return x
 }