-
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: Ops require their own extensions #734
Changes from all commits
f1e1e6f
cdc5785
9e1b3eb
b47ad17
bb66a8b
35e1787
1da3a63
6c76919
25852a3
4856b17
d07d186
dee0825
5ae9281
265df79
b87c884
97f9b87
9f51a9b
bc585f4
4721505
91c1b22
3a281c4
89cea89
6f0b215
4c4bb87
b8de62f
b407523
7f59d6f
66bff43
fe8eaf1
22c4458
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 |
---|---|---|
|
@@ -223,7 +223,7 @@ impl SignatureFunc { | |
/// | ||
/// This function will return an error if the type arguments are invalid or | ||
/// there is some error in type computation. | ||
pub fn compute_signature( | ||
fn compute_signature( | ||
&self, | ||
def: &OpDef, | ||
args: &[TypeArg], | ||
|
@@ -245,10 +245,10 @@ impl SignatureFunc { | |
} | ||
}; | ||
|
||
let res = pf.instantiate(args, exts)?; | ||
// TODO bring this assert back once resource inference is done? | ||
// https://github.com/CQCL/hugr/issues/388 | ||
// debug_assert!(res.extension_reqs.contains(def.extension())); | ||
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 assert should stay in, no? 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 is now the inner function, called by the outer which modifies the result to add the necessary extra Extension. 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. But, seems we can now just do it here. A lot has changed since this PR started!! |
||
let mut res = pf.instantiate(args, exts)?; | ||
res.extension_reqs = res | ||
.extension_reqs | ||
.union(&ExtensionSet::singleton(def.extension())); | ||
Ok(res) | ||
} | ||
} | ||
|
@@ -541,10 +541,10 @@ mod test { | |
let args = [TypeArg::BoundedNat { n: 3 }, USIZE_T.into()]; | ||
assert_eq!( | ||
def.compute_signature(&args, &PRELUDE_REGISTRY), | ||
Ok(FunctionType::new( | ||
vec![USIZE_T; 3], | ||
vec![Type::new_tuple(vec![USIZE_T; 3])] | ||
)) | ||
Ok( | ||
FunctionType::new(vec![USIZE_T; 3], vec![Type::new_tuple(vec![USIZE_T; 3])]) | ||
.with_extension_delta(&ExtensionSet::singleton(&EXT_ID)) | ||
) | ||
); | ||
assert_eq!(def.validate_args(&args, &PRELUDE_REGISTRY, &[]), Ok(())); | ||
|
||
|
@@ -554,10 +554,10 @@ mod test { | |
let args = [TypeArg::BoundedNat { n: 3 }, tyvar.clone().into()]; | ||
assert_eq!( | ||
def.compute_signature(&args, &PRELUDE_REGISTRY), | ||
Ok(FunctionType::new( | ||
tyvars.clone(), | ||
vec![Type::new_tuple(tyvars)] | ||
)) | ||
Ok( | ||
FunctionType::new(tyvars.clone(), vec![Type::new_tuple(tyvars)]) | ||
.with_extension_delta(&ExtensionSet::singleton(&EXT_ID)) | ||
) | ||
); | ||
def.validate_args(&args, &PRELUDE_REGISTRY, &[TypeBound::Eq.into()]) | ||
.unwrap(); | ||
|
@@ -610,7 +610,8 @@ mod test { | |
def.validate_args(&args, &EMPTY_REG, &decls).unwrap(); | ||
assert_eq!( | ||
def.compute_signature(&args, &EMPTY_REG), | ||
Ok(FunctionType::new_endo(vec![tv])) | ||
Ok(FunctionType::new_endo(vec![tv]) | ||
.with_extension_delta(&ExtensionSet::singleton(&EXT_ID))) | ||
); | ||
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.
AFAICS solved constraints get removed here:
hugr/src/extension/infer.rs
Lines 633 to 635 in 6959c89
so we have to handle them somehow. However I haven't looked into this all that hard so may have missed something @croyzor ?