Closed robertodr closed 4 years ago
I see two options:
My preference goes to detecting and stopping to avoid surprises.
Agreed on detect-and-stop. Not so clear how you'd detect though.
We can build a graph of dependencies as we go through the tokens and then we check whether the graph is circular.
Sounds good, hopefully there's a library for that :smile:
I am tempted to program this myself as a little challenge. There are codes and libraries but they seem to be not lightweight for this relatively simple task.
I see a graph as a dictionary mapping a
to List[a]
.
I thought about it some more and I see no difficulties detecting cycles in a graph - the difficulty that I see is to translate defaults (and predicates?) into a graph since we use eval there and don't directly have access to the nodes of the graph.
Closed in favor of #76 which has an actual example of chained dependencies which might degenerate into being circular.
Can we have circular dependencies in default and predicate callables? If not, we need to document why. If yes, we need a way to stop parsing with a meaningful error message.