reject_edge_transposed.mx raw

   1  // A declared pair's ends are complementary: the parent is Edge[In, Out] and the
   2  // child Edge[Out, In]. Handing the PARENT to a target that takes the child type
   3  // is a type mismatch, not a runtime check (D22.6).
   4  //
   5  // expected: the spawn argument and the target parameter must agree
   6  package main
   7  
   8  type Req struct {
   9  	Body []byte `cap:"1024"`
  10  }
  11  
  12  func worker(ep Edge[Req, int32]) (closed chan struct{}) {
  13  	for {
  14  		select {
  15  		case <-closed:
  16  			return closed
  17  		case r := <-ep.Recv:
  18  			_ = r
  19  		}
  20  	}
  21  }
  22  
  23  func main() {
  24  	select {
  25  	case <-shutdown:
  26  		return
  27  	default:
  28  	}
  29  	parent, child := edge[int32, Req]{2}
  30  	_ = child
  31  	done := spawn(worker, parent)
  32  	close(parent.Send)
  33  	<-done
  34  }
  35