From b57b10f9926c93e5369d1f08900cb3f62d7be64e Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Thu, 21 Oct 2010 08:40:33 -0700 Subject: [PATCH] go/parser: consume auto-inserted semi when calling ParseExpr() Fixes #1170. R=rsc CC=golang-dev https://golang.org/cl/2622041 --- src/pkg/go/parser/interface.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pkg/go/parser/interface.go b/src/pkg/go/parser/interface.go index 39476f07204..e451a4fe3db 100644 --- a/src/pkg/go/parser/interface.go +++ b/src/pkg/go/parser/interface.go @@ -69,7 +69,11 @@ func ParseExpr(filename string, src interface{}) (ast.Expr, os.Error) { var p parser p.init(filename, data, 0) - return p.parseExpr(), p.parseEOF() + x := p.parseExpr() + if p.tok == token.SEMICOLON { + p.next() // consume automatically inserted semicolon, if any + } + return x, p.parseEOF() }