mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: don't panic on syntax error in select statement
Fixes #18092. Change-Id: I54e2da2e0f168c068f5e4a1b22ba508d78259168 Reviewed-on: https://go-review.googlesource.com/33658 TryBot-Result: Gobot Gobot <gobot@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
6f287fa2bb
commit
8fa0d85b38
2 changed files with 27 additions and 17 deletions
|
|
@ -1809,24 +1809,19 @@ func (p *parser) commClause() *CommClause {
|
|||
switch p.tok {
|
||||
case _Case:
|
||||
p.next()
|
||||
lhs := p.exprList()
|
||||
c.Comm = p.simpleStmt(nil, false)
|
||||
|
||||
if _, ok := lhs.(*ListExpr); !ok && p.tok == _Arrow {
|
||||
// lhs <- x
|
||||
} else {
|
||||
// lhs
|
||||
// lhs = <-x
|
||||
// lhs := <-x
|
||||
if p.tok == _Assign || p.tok == _Define {
|
||||
// TODO(gri) check that lhs has at most 2 entries
|
||||
} else if p.tok == _Colon {
|
||||
// TODO(gri) check that lhs has at most 1 entry
|
||||
} else {
|
||||
panic("unimplemented")
|
||||
}
|
||||
}
|
||||
|
||||
c.Comm = p.simpleStmt(lhs, false)
|
||||
// The syntax restricts the possible simple statements here to:
|
||||
//
|
||||
// lhs <- x (send statement)
|
||||
// <-x
|
||||
// lhs = <-x
|
||||
// lhs := <-x
|
||||
//
|
||||
// All these (and more) are recognized by simpleStmt and invalid
|
||||
// syntax trees are flagged later, during type checking.
|
||||
// TODO(gri) eventually may want to restrict valid syntax trees
|
||||
// here.
|
||||
|
||||
case _Default:
|
||||
p.next()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue