printer: check if specs exist before accessing them in genDecl printer

Checks that specs exist before attempting to access the first element in genDecl printer.

Change-Id: I3619bcabf6fec64c88b7a10cdb7be355e9e40559
GitHub-Last-Rev: 54cf699c96
GitHub-Pull-Request: golang/go#30823
Reviewed-on: https://go-review.googlesource.com/c/go/+/167390
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Patrick Barker 2019-03-14 02:51:02 +00:00 committed by Robert Griesemer
parent f2a18b1456
commit b130764043
1 changed files with 1 additions and 1 deletions

View File

@ -1568,7 +1568,7 @@ func (p *printer) genDecl(d *ast.GenDecl) {
}
p.print(d.Rparen, token.RPAREN)
} else {
} else if len(d.Specs) > 0 {
// single declaration
p.spec(d.Specs[0], 1, true)
}