From: griesemer Date: Tue, 17 Oct 2017 04:52:34 +0000 (-0700) Subject: cmd/compile/internal/parser: removed TODO (cleanup) X-Git-Tag: go1.10beta1~681 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=58cf881c1c61544d467b265950a942ec2aeb9d28;p=gostls13.git cmd/compile/internal/parser: removed TODO (cleanup) When an opening "{" of a block is missing and after advancing we find a closing "}", it's likely better to assume the end of the block. Fixed and removed TODO. Change-Id: I20c9b4ecca798933a7cd4cbf21185bd4ca04f5f7 Reviewed-on: https://go-review.googlesource.com/71291 Reviewed-by: Matthew Dempsky --- diff --git a/src/cmd/compile/internal/syntax/parser.go b/src/cmd/compile/internal/syntax/parser.go index 312ccec64e..8e47d8e723 100644 --- a/src/cmd/compile/internal/syntax/parser.go +++ b/src/cmd/compile/internal/syntax/parser.go @@ -1689,10 +1689,14 @@ func (p *parser) blockStmt(context string) *BlockStmt { s := new(BlockStmt) s.pos = p.pos() + // people coming from C may forget that braces are mandatory in Go if !p.got(_Lbrace) { p.syntax_error("expecting { after " + context) p.advance(_Name, _Rbrace) - // TODO(gri) may be better to return here than to continue (#19663) + s.Rbrace = p.pos() // in case we found "}" + if p.got(_Rbrace) { + return s + } } s.List = p.stmtList()