reject_edge_user_struct.mx raw

   1  // A struct with the same field names and types is not an Edge: the spawn
   2  // argument is matched to the target's parameter BY NAME (D19 rule 2), so only
   3  // the universe type satisfies it.
   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  type FakeEdge struct {
  13  	Recv Receiver[Req]
  14  	Send Sender[int32]
  15  }
  16  
  17  func worker(ep Edge[Req, int32]) (closed chan struct{}) {
  18  	for {
  19  		select {
  20  		case <-closed:
  21  			return closed
  22  		case r := <-ep.Recv:
  23  			_ = r
  24  		}
  25  	}
  26  }
  27  
  28  func main() {
  29  	select {
  30  	case <-shutdown:
  31  		return
  32  	default:
  33  	}
  34  	parent, child := edge[int32, Req]{2}
  35  	_ = child
  36  	var fake FakeEdge
  37  	done := spawn(worker, fake)
  38  	close(parent.Send)
  39  	<-done
  40  }
  41