Commit 28f19140 authored by Robert Griesemer's avatar Robert Griesemer

Handle presence of illegal semicolon after package clause better.

R=r, r1
https://golang.org/cl/157167
parent a38ec58d
......@@ -1977,6 +1977,14 @@ func (p *parser) parseFile() *ast.File {
doc := p.leadComment;
pos := p.expect(token.PACKAGE);
ident := p.parseIdent();
// Common error: semicolon after package clause.
// Accept and report it for better error synchronization.
if p.tok == token.SEMICOLON {
p.Error(p.pos, "expected declaration, found ';'");
p.next();
}
var decls []ast.Decl;
// Don't bother parsing the rest if we had errors already.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment