diff --git a/parser/parser.go b/parser/parser.go index afcfa25c0..2fc8a509c 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -3648,7 +3648,7 @@ func (p *parser) parseGlobalStmts(sync map[token.Token]bool, pos token.Pos, stmt p.advance(sync) } if p.tok != token.EOF { - p.expect(token.SEMICOLON) + p.errorExpected(p.pos, "statement", 2) } f := &ast.FuncDecl{ Name: &ast.Ident{NamePos: pos, Name: "main"}, diff --git a/parser/parser_test.go b/parser/parser_test.go index 1d6c66484..bb6c4bb13 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -510,7 +510,7 @@ const d func TestErrGlobal(t *testing.T) { testErrCode(t, `func test() {} -}`, `/foo/bar.gop:2:1: expected ';', found '}'`, ``) +}`, `/foo/bar.gop:2:1: expected statement, found '}'`, ``) } // -----------------------------------------------------------------------------