typechecklist(ncase->nbody, Etop);
}
sel->xoffset = count;
- if(count == 0)
- yyerror("empty select");
lineno = lno;
}
typecheck(&r, Etop);
init = list(init, r);
- if(sel->list == nil)
+ if(sel->list == nil && sel->xoffset != 0)
fatal("double walkselect"); // already rewrote
// register cases
printf("select: sel=%p\n", sel);
if(sel->ncase < 2) {
- if(sel->ncase < 1)
- throw("select: no cases");
- // make special case of one.
+ if(sel->ncase < 1) {
+ g->status = Gwaiting; // forever
+ gosched();
+ }
+ // TODO: make special case of one.
}
// select a (relative) prime
<-ch
})
- // TODO(gri) remove this if once 6g accepts empty selects
- enabled := false
- if enabled {
- // empty selects always block
- testBlock(always, func() {
- select {
- case <-make(chan int): // remove this once 6g accepts empty selects
- }
- })
+ // empty selects always block
+ testBlock(always, func() {
+ select {
+ }
+ })
- // selects with only nil channels always block
- testBlock(always, func() {
- select {
- case <-nilch:
- unreachable()
- }
- })
- testBlock(always, func() {
- select {
- case nilch <- 7:
- unreachable()
- }
- })
- testBlock(always, func() {
- select {
- case <-nilch:
- unreachable()
- case nilch <- 7:
- unreachable()
- }
- })
- }
+ // selects with only nil channels always block
+ testBlock(always, func() {
+ select {
+ case <-nilch:
+ unreachable()
+ }
+ })
+ testBlock(always, func() {
+ select {
+ case nilch <- 7:
+ unreachable()
+ }
+ })
+ testBlock(always, func() {
+ select {
+ case <-nilch:
+ unreachable()
+ case nilch <- 7:
+ unreachable()
+ }
+ })
// selects with non-ready non-nil channels always block
testBlock(always, func() {