mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile/internal/types2: catch unexpected expression lists
This is a modified port of the https://golang.org/cl/313909 change for go/types. - add catch-all cases for unexpected expression lists - add Checker.singleIndex function to check single indices - better syntax error handling in parser for invalid type instantiations that are missing a type argument Change-Id: I6f0f396d637ad66b79f803d886fdc20ee55a98b3 Reviewed-on: https://go-review.googlesource.com/c/go/+/314409 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
90614ff462
commit
ea65a12f89
5 changed files with 86 additions and 26 deletions
|
|
@ -1291,16 +1291,15 @@ func (p *parser) typeInstance(typ Expr) Expr {
|
|||
|
||||
pos := p.pos()
|
||||
p.want(_Lbrack)
|
||||
if p.tok == _Rbrack {
|
||||
p.error("expecting type")
|
||||
p.next()
|
||||
return typ
|
||||
}
|
||||
|
||||
x := new(IndexExpr)
|
||||
x.pos = pos
|
||||
x.X = typ
|
||||
x.Index, _ = p.typeList()
|
||||
if p.tok == _Rbrack {
|
||||
p.syntaxError("expecting type")
|
||||
x.Index = p.badExpr()
|
||||
} else {
|
||||
x.Index, _ = p.typeList()
|
||||
}
|
||||
p.want(_Rbrack)
|
||||
return x
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue