-
Notifications
You must be signed in to change notification settings - Fork 7
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
Infer extension constraints on FuncDefn; remove many ExtensionSets from builder #739
Changes from all commits
1e98cd9
3ba96b4
4250bbf
d69833e
acfd019
c80b051
bee23a2
a85c7fc
2e15797
75e03e6
ef5a429
014f204
66cdbc5
651b6c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,8 @@ use std::error::Error; | |
use super::*; | ||
use crate::builder::test::closed_dfg_root_hugr; | ||
use crate::builder::{ | ||
Container, DFGBuilder, Dataflow, DataflowHugr, DataflowSubContainer, HugrBuilder, ModuleBuilder, | ||
BuildError, Container, DFGBuilder, Dataflow, DataflowHugr, DataflowSubContainer, | ||
FunctionBuilder, HugrBuilder, ModuleBuilder, | ||
}; | ||
use crate::extension::prelude::QB_T; | ||
use crate::extension::ExtensionId; | ||
|
@@ -154,36 +155,25 @@ fn plus() -> Result<(), InferExtensionError> { | |
} | ||
|
||
#[test] | ||
// This generates a solution that causes validation to fail | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment was incorrect (it doesn't generate a solution - the error is CantInfer). But the body/subject of this test has largely switched with the identically-named test in validation. |
||
// because of a missing lift node | ||
// We can't infer a solution here because of a missing lift node between | ||
// Input and Output | ||
fn missing_lift_node() -> Result<(), Box<dyn Error>> { | ||
let mut hugr = Hugr::new(NodeType::new_pure(ops::DFG { | ||
signature: FunctionType::new(type_row![NAT], type_row![NAT]) | ||
.with_extension_delta(&ExtensionSet::singleton(&A)), | ||
})); | ||
|
||
let input = hugr.add_node_with_parent( | ||
hugr.root(), | ||
NodeType::new_pure(ops::Input { | ||
types: type_row![NAT], | ||
}), | ||
)?; | ||
|
||
let output = hugr.add_node_with_parent( | ||
hugr.root(), | ||
NodeType::new_pure(ops::Output { | ||
types: type_row![NAT], | ||
}), | ||
let main = FunctionBuilder::new( | ||
"main", | ||
FunctionType::new_endo(type_row![NAT]) | ||
.with_extension_delta(&ExtensionSet::singleton(&A)) | ||
.into(), | ||
)?; | ||
|
||
hugr.connect(input, 0, output, 0)?; | ||
let [inps] = main.input_wires_arr(); | ||
let result = main.finish_prelude_hugr_with_outputs([inps]); | ||
|
||
// Fail to catch the actual error because it's a difference between I/O | ||
// Don't try to match the actual error because it's a difference between I/O | ||
// nodes and their parents and `report_mismatch` isn't yet smart enough | ||
// to handle that. | ||
assert_matches!( | ||
hugr.update_validate(&PRELUDE_REGISTRY), | ||
Err(ValidationError::CantInfer(_)) | ||
result, | ||
Err(BuildError::InvalidHUGR(ValidationError::CantInfer(_))) | ||
); | ||
Ok(()) | ||
} | ||
|
@@ -996,6 +986,7 @@ fn funcdefn_signature_mismatch() -> Result<(), Box<dyn Error>> { | |
result, | ||
Err(ValidationError::CantInfer( | ||
InferExtensionError::MismatchedConcreteWithLocations { .. } | ||
| InferExtensionError::EdgeMismatch(ExtensionError::SrcExceedsTgtExtensions { .. }) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one is a bit nondeterministic as to which error is reported |
||
)) | ||
); | ||
Ok(()) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The choice of new_auto here is about the only non-obvious thing in the PR. ("pure" for
FuncDefn
but "open" for any other DFG.) I think the next PR might even remove new_auto and that could be a good point to say #702 is finished