Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect cyclic DAGs in validation #435

Closed
acl-cqc opened this issue Aug 22, 2023 · 0 comments · Fixed by #468
Closed

Detect cyclic DAGs in validation #435

acl-cqc opened this issue Aug 22, 2023 · 0 comments · Fixed by #468
Assignees

Comments

@acl-cqc
Copy link
Contributor

acl-cqc commented Aug 22, 2023

As per #228, this test creates a cyclic DAG but validation is "happy":

   #[test]
    fn test_cyclic() -> Result<(), HugrError> {
        let mut h = Hugr::new(NodeType::pure(ops::DFG {
            signature: FunctionType::new(type_row![QB_T], type_row![QB_T]),
        }));
        let input = h.add_op_with_parent(h.root(), ops::Input::new(type_row![QB_T]))?;
        let output = h.add_op_with_parent(h.root(), ops::Output::new(type_row![QB_T]))?;
        let cx = h.add_op_with_parent(h.root(), cx_gate())?;
        h.connect(input, 0, cx, 0)?;
        h.connect(cx, 0, output, 0)?;
        h.connect(cx, 1, cx, 1)?;
        h.validate().unwrap(); // TODO this should raise an error
        Ok(())
    }

Instead we should probably get a ValidationError::NotABoundedDag (or perhaps a new error, but anything cyclic clearly isn't any sort of DAG bounded or otherwise)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants