aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/typecheck/stmt.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2020-12-26 23:03:25 -0800
committerMatthew Dempsky <mdempsky@google.com>2020-12-28 08:02:30 +0000
commit3bdafb0d82c9908ae04d2765847754df0646df35 (patch)
tree58ace2f281109e01ec8a80eea335b29a9c72fc7d /src/cmd/compile/internal/typecheck/stmt.go
parent2ecf52b841cd48e76df1fe721d29a972c22bf93f (diff)
downloadgo-3bdafb0d82c9908ae04d2765847754df0646df35.tar.gz
go-3bdafb0d82c9908ae04d2765847754df0646df35.zip
[dev.regabi] cmd/compile: remove CommStmt.List
Package syntax's parser already ensures that select communication clauses only have one statement, so there's no need for ir's CommStmt to need to represent more than one. Instead, noder can just directly populate Comm in the first place. Incidentally, this also revealed a latent issue in the inline-body exporter: we were exporting List (where the case statement is before type-checking), rather than Comm (where the case statement would be after type-checking, when export happens). Passes toolstash -cmp. Change-Id: Ib4eb711527bed297c7332c79ed6e6562a1db2cfa Reviewed-on: https://go-review.googlesource.com/c/go/+/280444 Trust: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'src/cmd/compile/internal/typecheck/stmt.go')
-rw-r--r--src/cmd/compile/internal/typecheck/stmt.go18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/cmd/compile/internal/typecheck/stmt.go b/src/cmd/compile/internal/typecheck/stmt.go
index 03c3e399eb..bfeea06e83 100644
--- a/src/cmd/compile/internal/typecheck/stmt.go
+++ b/src/cmd/compile/internal/typecheck/stmt.go
@@ -360,29 +360,23 @@ func tcReturn(n *ir.ReturnStmt) ir.Node {
// select
func tcSelect(sel *ir.SelectStmt) {
- var def ir.Node
+ var def *ir.CommStmt
lno := ir.SetPos(sel)
Stmts(sel.Init())
for _, ncase := range sel.Cases {
- if len(ncase.List) == 0 {
+ if ncase.Comm == nil {
// default
if def != nil {
base.ErrorfAt(ncase.Pos(), "multiple defaults in select (first at %v)", ir.Line(def))
} else {
def = ncase
}
- } else if len(ncase.List) > 1 {
- base.ErrorfAt(ncase.Pos(), "select cases cannot be lists")
} else {
- ncase.List[0] = Stmt(ncase.List[0])
- n := ncase.List[0]
+ n := Stmt(ncase.Comm)
ncase.Comm = n
- ncase.List.Set(nil)
- oselrecv2 := func(dst, recv ir.Node, colas bool) {
- n := ir.NewAssignListStmt(n.Pos(), ir.OSELRECV2, nil, nil)
- n.Lhs = []ir.Node{dst, ir.BlankNode}
- n.Rhs = []ir.Node{recv}
- n.Def = colas
+ oselrecv2 := func(dst, recv ir.Node, def bool) {
+ n := ir.NewAssignListStmt(n.Pos(), ir.OSELRECV2, []ir.Node{dst, ir.BlankNode}, []ir.Node{recv})
+ n.Def = def
n.SetTypecheck(1)
ncase.Comm = n
}