aboutsummaryrefslogtreecommitdiff
path: root/src/go/parser/parser.go
diff options
context:
space:
mode:
authorAlan Donovan <adonovan@google.com>2015-05-20 15:49:23 -0400
committerAlan Donovan <adonovan@google.com>2015-05-20 20:57:49 +0000
commitceb8fe45da7042b20189de0b66db5b33bb589f7b (patch)
tree98ad82ee889a63e355593eef5794f1c58f4e90d1 /src/go/parser/parser.go
parent8401b19e7e6bf60d66b2d71cd3fa2215c4649d31 (diff)
downloadgo-ceb8fe45da7042b20189de0b66db5b33bb589f7b.tar.gz
go-ceb8fe45da7042b20189de0b66db5b33bb589f7b.zip
go/parser: parse incomplete selection "fmt." as a blank selection "fmt._"
Formerly it would return a BadExpr. This prevents partial syntax from being discarded, and makes the error recovery logic more consistent with other places where an identifier was expected but not found. + test Change-Id: I223c0c0589e7ceb7207ae951b8f71b9275a1eb73 Reviewed-on: https://go-review.googlesource.com/10269 Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/go/parser/parser.go')
-rw-r--r--src/go/parser/parser.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/go/parser/parser.go b/src/go/parser/parser.go
index fb6ca76a77..18278ba4b7 100644
--- a/src/go/parser/parser.go
+++ b/src/go/parser/parser.go
@@ -1472,7 +1472,8 @@ L:
pos := p.pos
p.errorExpected(pos, "selector or type assertion")
p.next() // make progress
- x = &ast.BadExpr{From: pos, To: p.pos}
+ sel := &ast.Ident{NamePos: pos, Name: "_"}
+ x = &ast.SelectorExpr{X: x, Sel: sel}
}
case token.LBRACK:
if lhs {