-
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
fix: FuncDefns don't require that their extensions match their children #688
Changes from all commits
f2963a4
64fbfc3
d416543
3f87b8d
72d8013
bbbdb17
7671d02
97a55a8
0cdd1ee
417ffc1
cfd51f8
31d2d54
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 |
---|---|---|
|
@@ -565,7 +565,7 @@ fn extensions_mismatch() -> Result<(), BuildError> { | |
assert_matches!( | ||
handle, | ||
Err(ValidationError::ExtensionError( | ||
ExtensionError::ParentIOExtensionMismatch { .. } | ||
ExtensionError::TgtExceedsSrcExtensionsAtPort { .. } | ||
)) | ||
); | ||
Ok(()) | ||
|
@@ -752,3 +752,53 @@ fn invalid_types() { | |
SignatureError::TypeArgMismatch(TypeArgError::WrongNumberArgs(2, 1)) | ||
); | ||
} | ||
|
||
#[test] | ||
fn parent_io_mismatch() { | ||
// The DFG node declares that it has an empty extension delta, | ||
// but it's child graph adds extension "XB", causing a mismatch. | ||
let mut hugr = Hugr::new(NodeType::new_pure(ops::DFG { | ||
signature: FunctionType::new(type_row![USIZE_T], type_row![USIZE_T]), | ||
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. The problem here is that the FunctionType has zero delta? Whereas if you did 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. Added a comment explaining this |
||
})); | ||
|
||
let input = hugr | ||
.add_node_with_parent( | ||
hugr.root(), | ||
NodeType::new_pure(ops::Input { | ||
types: type_row![USIZE_T], | ||
}), | ||
) | ||
.unwrap(); | ||
let output = hugr | ||
.add_node_with_parent( | ||
hugr.root(), | ||
NodeType::new( | ||
ops::Output { | ||
types: type_row![USIZE_T], | ||
}, | ||
ExtensionSet::singleton(&XB), | ||
), | ||
) | ||
.unwrap(); | ||
|
||
let lift = hugr | ||
.add_node_with_parent( | ||
hugr.root(), | ||
NodeType::new_pure(ops::LeafOp::Lift { | ||
type_row: type_row![USIZE_T], | ||
new_extension: XB, | ||
}), | ||
) | ||
.unwrap(); | ||
|
||
hugr.connect(input, 0, lift, 0).unwrap(); | ||
hugr.connect(lift, 0, output, 0).unwrap(); | ||
|
||
let result = hugr.validate(&PRELUDE_REGISTRY); | ||
assert_matches!( | ||
result, | ||
Err(ValidationError::ExtensionError( | ||
ExtensionError::ParentIOExtensionMismatch { .. } | ||
)) | ||
); | ||
} |
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.
ok, that is neater than I realized, nice
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.
Hang on. (Hang on!) Don't we need an additional constraint, then, that the (input-extensions to the) Output node are Plus of (the delta of the FuncDefn's declared FunctionType and the Input node)?
Could add a test of a FuncDefn that declares delta is {A} and then has a body that Lift's only by {B}, say - that should be rejected, but is it?
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.
I've added a test for this "funcdefn_signature_mismatch"