aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/syntax/parser.go
diff options
context:
space:
mode:
authorgriesemer <gri@golang.org>2017-10-16 21:52:34 -0700
committerRobert Griesemer <gri@golang.org>2017-10-17 17:00:15 +0000
commit58cf881c1c61544d467b265950a942ec2aeb9d28 (patch)
tree693d7fa1a74ed9d8c0c2e51aae2853f8b1dc60a3 /src/cmd/compile/internal/syntax/parser.go
parentc37090f00f57b38b4c8b93b1d5e97f5a10cb1765 (diff)
downloadgo-58cf881c1c61544d467b265950a942ec2aeb9d28.tar.gz
go-58cf881c1c61544d467b265950a942ec2aeb9d28.zip
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 <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/syntax/parser.go')
-rw-r--r--src/cmd/compile/internal/syntax/parser.go6
1 files changed, 5 insertions, 1 deletions
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()