1
0
mirror of https://github.com/golang/go synced 2024-10-05 21:21:21 -06:00
go/src/cmd/gofmt
Robert Griesemer 670642d389 go/parser, go/types: report invalid else branch in if statements
- Only accept valid if statement syntax in go/parser.

- Check AST again in go/types since it may have been modified and the
  AST doesn't preclude other statements in the else branch of an if
  statement.

- Removed a test from gofmt which verified that old-style if statements
  permitting any statement in the else branch were correctly reformatted.
  It's been years since we switched to the current syntax; no need to
  support this anymore.

- Added a comment to go/printer.

Fixes #13475.

Change-Id: Id2c8fbcc68b719cd511027d0412a37266cceed6b
Reviewed-on: https://go-review.googlesource.com/17408
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-07 21:36:31 +00:00
..
testdata go/parser, go/types: report invalid else branch in if statements 2015-12-07 21:36:31 +00:00
doc.go gofmt/doc: gofmt -s output may not be backward compatible 2015-02-08 05:13:00 +00:00
gofmt_test.go cmd/gofmt: make test files self-describing 2014-08-21 17:25:13 -07:00
gofmt.go go/format, cmd/gofmt: avoid dependency on internal package format 2015-09-30 16:32:47 +00:00
internal.go go/format: handle whitespace-only input correctly 2015-09-30 16:39:43 +00:00
long_test.go go/format, cmd/gofmt: avoid dependency on internal package format 2015-09-30 16:32:47 +00:00
rewrite.go all: use "reports whether" in place of "returns true if(f)" 2015-03-18 15:14:06 +00:00
simplify.go gofmt: -s flag simplifies "for _ = range x" 2014-07-17 09:40:27 -07:00