Skip to content

Commit

Permalink
instantiate_all => instantiate
Browse files Browse the repository at this point in the history
  • Loading branch information
acl-cqc committed Nov 7, 2023
1 parent 3584036 commit c7c8d09
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/extension/op_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ impl OpDef {
}
};

let res = pf.instantiate_all(args, exts)?;
let res = pf.instantiate(args, exts)?;
// TODO bring this assert back once resource inference is done?
// https://github.com/CQCL-DEV/hugr/issues/425
// assert!(res.contains(self.extension()));
Expand Down
18 changes: 9 additions & 9 deletions src/types/poly_func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl PolyFuncType {
let remaining = self.params.get(args.len()..).unwrap_or_default();
let mut v;
let args = if remaining.is_empty() {
args // instantiate_all below will fail if there were too many
args // instantiate below will fail if there were too many
} else {
// Partial application - renumber remaining params (still bound) downward
v = args.to_vec();
Expand All @@ -124,7 +124,7 @@ impl PolyFuncType {
};
Ok(Self {
params: remaining.to_vec(),
body: self.instantiate_all(args, exts)?,
body: self.instantiate(args, exts)?,
})
}

Expand All @@ -134,7 +134,7 @@ impl PolyFuncType {
/// # Errors
/// If there is not exactly one [TypeArg] for each binder ([Self::params]),
/// or an arg does not fit into its corresponding [TypeParam]
pub(crate) fn instantiate_all(
pub(crate) fn instantiate(
&self,
args: &[TypeArg],
ext_reg: &ExtensionRegistry,
Expand Down Expand Up @@ -249,7 +249,7 @@ pub(crate) mod test {
&reg,
)?;

let t = list_len.instantiate_all(&[TypeArg::Type { ty: USIZE_T }], &reg)?;
let t = list_len.instantiate(&[TypeArg::Type { ty: USIZE_T }], &reg)?;
assert_eq!(
t,
FunctionType::new(
Expand Down Expand Up @@ -282,12 +282,12 @@ pub(crate) mod test {
PolyFuncType::new_validated(typarams.clone(), id_fn(good_array), &PRELUDE_REGISTRY)?;

// Sanity check (good args)
good_ts.instantiate_all(
good_ts.instantiate(
&[TypeArg::Type { ty: USIZE_T }, TypeArg::BoundedNat { n: 5 }],
&PRELUDE_REGISTRY,
)?;

let wrong_args = good_ts.instantiate_all(
let wrong_args = good_ts.instantiate(
&[TypeArg::BoundedNat { n: 5 }, TypeArg::Type { ty: USIZE_T }],
&PRELUDE_REGISTRY,
);
Expand Down Expand Up @@ -551,7 +551,7 @@ pub(crate) mod test {
))],
);

let res = outer.instantiate_all(&[TypeArg::Type { ty: arg }], &reg)?;
let res = outer.instantiate(&[TypeArg::Type { ty: arg }], &reg)?;
assert_eq!(res, outer_applied);
Ok(())
}
Expand All @@ -565,7 +565,7 @@ pub(crate) mod test {
const FREE: usize = 3;
const TP_EQ: TypeParam = TypeParam::Type(TypeBound::Eq);
let res = outer
.instantiate_all(&[TypeArg::new_var_use(FREE, TP_EQ)], &reg)
.instantiate(&[TypeArg::new_var_use(FREE, TP_EQ)], &reg)
.unwrap();
assert_eq!(
res,
Expand Down Expand Up @@ -598,7 +598,7 @@ pub(crate) mod test {
};

let res = outer
.instantiate_all(&[TypeArg::Type { ty: rhs(FREE) }], &reg)
.instantiate(&[TypeArg::Type { ty: rhs(FREE) }], &reg)
.unwrap();
assert_eq!(
res,
Expand Down

0 comments on commit c7c8d09

Please sign in to comment.