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

ConditionalBuilder allows adding of scoped definitions that break validation #1903

Open
acl-cqc opened this issue Feb 3, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@acl-cqc
Copy link
Contributor

acl-cqc commented Feb 3, 2025

let mut cb = ConditionalBuilder::new(vec![type_row![]; 2], type_row![], usize_t()).unwrap();
let cst = cb.add_constant(Value::from(ConstUsize::new(29)));
let mut case0 = cb.case_builder(0).unwrap();
let c = case0.load_const(&cst);
let case0 = case0.finish_with_outputs([c]).unwrap().node();
let mut case1 = cb.case_builder(1).unwrap();
let c = case1.load_const(&cst);
let case1 = case1.finish_with_outputs([c]).unwrap().node();
let orig = cb.finish_hugr().unwrap();

I'm not really sure whether

  1. validation should accept this Hugr; the conditional should be compiled that the first Case should be used for the first tag of the predicate, rather than "the first child"; or
  2. ConditionalBuilder should not implement the trait defining add_constant (and all the others - e.g. local functions).

It's not useful to say you have to add all the Cases before the other scoped defns as you then wouldn't be able to use the latter.

@acl-cqc acl-cqc added the bug Something isn't working label Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant