Skip to content

Commit

Permalink
check all gamma branches built when finish
Browse files Browse the repository at this point in the history
  • Loading branch information
ss2165 committed May 4, 2023
1 parent 13ac458 commit 72c04bc
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ pub struct GammaBuilder<'f> {
}

impl<'f> Container for GammaBuilder<'f> {
type ContainerHandle = GammaID;
type ContainerHandle = Result<GammaID, GammaBuildError>;

#[inline]
fn container_node(&self) -> NodeIndex {
Expand All @@ -796,8 +796,13 @@ impl<'f> Container for GammaBuilder<'f> {
}

fn finish(self) -> Self::ContainerHandle {
// TODO check all branches built
(self.gamma_node, self.n_out_wires).into()
if !self.remaining_branches.is_empty() {
return Err(GammaBuildError::NotAllBranchesBuiltError {
gamma: self.gamma_node,
branches: self.remaining_branches,
});
}
Ok((self.gamma_node, self.n_out_wires).into())
}
}

Expand Down Expand Up @@ -999,7 +1004,7 @@ mod test {
n_identity(gamma_b.branch_builder(0)?)?;
n_identity(gamma_b.branch_builder(1)?)?;

gamma_b.finish()
gamma_b.finish()?
};
let [unit, int] = gamma.outputs_arr();
fbuild.discard(unit)?;
Expand Down Expand Up @@ -1056,7 +1061,7 @@ mod test {
let break_wire = branch_1.make_break(signature, [wire])?;
branch_1.finish_with_outputs([break_wire])?;

gamma_b.finish()
gamma_b.finish()?
};

theta_b.finish_with_outputs(gamma.out_wire(0))?
Expand Down

0 comments on commit 72c04bc

Please sign in to comment.