Limit the number of coroutines per type to 0x7FFF
diff --git a/internal/cgen/func.go b/internal/cgen/func.go
index f85b1cc..eca0bed 100644
--- a/internal/cgen/func.go
+++ b/internal/cgen/func.go
@@ -292,6 +292,9 @@
 	if n.Public() && n.Effect().Coroutine() {
 		g.numPublicCoroutines[n.Receiver()]++
 		coroID = g.numPublicCoroutines[n.Receiver()]
+		if coroID >= 0x8000 {
+			return fmt.Errorf("too many coroutines for %q", n.Receiver().Str(g.tm))
+		}
 	}
 
 	g.currFunk = funk{