Skip to content

Commit

Permalink
check for cycles in visitor2
Browse files Browse the repository at this point in the history
  • Loading branch information
Natoandro committed Dec 16, 2024
1 parent 64ed210 commit 319fc4b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/common/src/typegraph/visitor2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,15 @@ fn traverse_types_with_path<'tg, A, V, E>(
where
V: Fn(VisitorContext<'tg>, &mut A) -> Result<VisitNext, E>,
{
let cyclic = path.borrow().iter().any(|segment| segment.from == type_idx);
if cyclic {
return Ok(TraverseOutput {
accumulator,
stop: false,
});
}

let type_node = &tg.types[type_idx as usize];
// TODO check for cycles

// visit current
{
Expand Down
1 change: 1 addition & 0 deletions tests/metagen/typegraphs/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def example(g: Graph):
"email": t.email().optional(),
"list_integer": t.list(t.integer()),
"opt_union_flat": t.union([t.integer(), t.float()]).optional(),
"file": t.file().optional(),
"reference": t.list(g.ref("Example")).optional(),
"nested_ref": t.struct(
{"either": t.either([g.ref("Example"), references])}
Expand Down

0 comments on commit 319fc4b

Please sign in to comment.