]> Cypherpunks repositories - gostls13.git/commit
go/parser, go/types: report invalid else branch in if statements
authorRobert Griesemer <gri@golang.org>
Fri, 4 Dec 2015 01:28:46 +0000 (17:28 -0800)
committerRobert Griesemer <gri@golang.org>
Mon, 7 Dec 2015 21:36:31 +0000 (21:36 +0000)
commit670642d389a3c1a90fad6016f91197125969376d
treec344c5658d0a942fac1d66843fca76bc4a46cc62
parentc5aa53c8c52ec895d7e7c18a8fab9c5786555c1a
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>
src/cmd/gofmt/testdata/old.golden [deleted file]
src/cmd/gofmt/testdata/old.input [deleted file]
src/go/parser/parser.go
src/go/parser/short_test.go
src/go/printer/nodes.go
src/go/types/stmt.go