case ir.OSELRECV2:
// case x, ok = <-c
+ r := r.(*ir.AssignListStmt)
recv := r.Rlist().First().(*ir.UnaryExpr)
recv.SetLeft(o.expr(recv.Left(), nil))
if recv.Left().Op() != ir.ONAME {
recv.SetLeft(o.copyExpr(recv.Left()))
}
- r := r.(*ir.AssignListStmt)
init := r.PtrInit().Slice()
r.PtrInit().Set(nil)
if len(init) > 0 && init[0].Op() == ir.ODCL && init[0].(*ir.Decl).Left() == n {
init = init[1:]
}
- dcl := ir.Nod(ir.ODCL, n, nil)
- dcl = typecheck(dcl, ctxStmt)
+ dcl := typecheck(ir.Nod(ir.ODCL, n, nil), ctxStmt)
ncas.PtrInit().Append(dcl)
}
tmp := o.newTemp(t, t.HasPointers())
- as := ir.Nod(ir.OAS, n, conv(tmp, n.Type()))
- as = typecheck(as, ctxStmt)
+ as := typecheck(ir.Nod(ir.OAS, n, conv(tmp, n.Type())), ctxStmt)
ncas.PtrInit().Append(as)
r.PtrList().SetIndex(i, tmp)
}
} else {
// TODO(cuonglm): make this use selectnbrecv()
// if selectnbrecv2(&v, &received, c) { body } else { default body }
- receivedp := ir.Nod(ir.OADDR, n.List().Second(), nil)
- receivedp = typecheck(receivedp, ctxExpr)
+ receivedp := typecheck(nodAddr(n.List().Second()), ctxExpr)
call = mkcall1(chanfn("selectnbrecv2", 2, ch.Type()), types.Types[types.TBOOL], r.PtrInit(), elem, receivedp, ch)
}
}
r := ir.Nod(ir.OIF, cond, nil)
- if n := cas.Left(); n != nil && n.Op() == ir.OSELRECV2 && !ir.IsBlank(n.List().Second()) {
- x := ir.Nod(ir.OAS, n.List().Second(), recvOK)
- r.PtrBody().Append(typecheck(x, ctxStmt))
+ if n := cas.Left(); n != nil && n.Op() == ir.OSELRECV2 {
+ if !ir.IsBlank(n.List().Second()) {
+ x := ir.Nod(ir.OAS, n.List().Second(), recvOK)
+ r.PtrBody().Append(typecheck(x, ctxStmt))
+ }
}
r.PtrBody().AppendNodes(cas.PtrBody())