-
Notifications
You must be signed in to change notification settings - Fork 23
Description
It's not something that we have found a hard requirement for yet, but it is something that has come up once or twice for a friend that it's not possible to derive HasSchema for a recursive type. I.e.
struct Expr {
Vec(Vec<Expr>),
String(String),
None,
}The issue is with the first variant in which Expr references Expr. In the schema derive, we want to then find out the schema of Expr and stick it in the Vec<Expr>, but the problem is that we're in the middle of actively building the Expr schema. This causes an infinite loop of trying to build the schema of Expr so we can build the schema Expr and so on.
One possible solution would be to have something like a self or parent placeholder so that the schema could refer to it's own schema, but I'm not actually sure if that works or not.
Another interesting idea in a related dilemma for content-addressed self-referentiality is this one here:
https://whtwnd.com/makoconstruct.bsky.social/3lcdzw5oqh62t
It could work, but I haven't thought all the way through it. I just wanted to drop it here so it isn't forgotten.
Summary of the idea from that post:
