self.outputs = tuple(outputs)
fixed_locs = [] # type: list[tuple[Loc, int]]
for idx, out in enumerate(self.outputs):
- if out.tied_input_index is not None \
- and out.tied_input_index >= len(self.inputs):
- raise ValueError(f"tied_input_index out of range: {out}")
+ if out.tied_input_index is not None:
+ if out.tied_input_index >= len(self.inputs):
+ raise ValueError(f"tied_input_index out of range: {out}")
+ tied_inp = self.inputs[out.tied_input_index]
+ if tied_inp.tied_to_input(out.tied_input_index) != out:
+ raise ValueError(f"output can't be tied to non-equivalent "
+ f"input: {out} tied to {tied_inp}")
if out.fixed_loc is not None:
for other_fixed_loc, other_idx in fixed_locs:
if not other_fixed_loc.conflicts(out.fixed_loc):