Skip to content

Commit

Permalink
fix: Special case FuncDefn in extension validation
Browse files Browse the repository at this point in the history
  • Loading branch information
croyzor committed Nov 14, 2023
1 parent 867af89 commit f2963a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions src/hugr/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,15 @@ impl<'a, 'b> ValidationContext<'a, 'b> {
// Secondly that the node has correct children
self.validate_children(node, node_type)?;

// If this is a container with I/O nodes, check that the extension they
// define match the extensions of the container.
if let Some([input, output]) = self.hugr.get_io(node) {
self.extension_validator
.validate_io_extensions(node, input, output)?;
// FuncDefns have no resources since they're static nodes, but the
// functions they define can have any extension delta.
if node_type.tag() != OpTag::FuncDefn {
// If this is a container with I/O nodes, check that the extension they
// define match the extensions of the container.
if let Some([input, output]) = self.hugr.get_io(node) {
self.extension_validator
.validate_io_extensions(node, input, output)?;
}
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/hugr/validate/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ fn extensions_mismatch() -> Result<(), BuildError> {
assert_matches!(
handle,
Err(ValidationError::ExtensionError(
ExtensionError::ParentIOExtensionMismatch { .. }
ExtensionError::TgtExceedsSrcExtensionsAtPort { .. }
))
);
Ok(())
Expand Down

0 comments on commit f2963a4

Please sign in to comment.