Skip to content

Commit 3943499

Browse files
authored
fix: Fix model export of Opaque types. (#2446)
This PR fixes a bug in `hugr-py` model export: `Opaque` types forgot to mention their extension id.
1 parent 1a301eb commit 3943499

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

hugr-py/src/hugr/tys.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -767,15 +767,7 @@ def __eq__(self, value):
767767
return super().__eq__(value)
768768

769769
def to_model(self) -> model.Term:
770-
# This cast is only neccessary because `Type` can both be an
771-
# actual type or a row variable.
772-
args = [cast(model.Term, arg.to_model()) for arg in self.args]
773-
774-
extension_name = self.type_def.get_extension().name
775-
type_name = self.type_def.name
776-
name = f"{extension_name}.{type_name}"
777-
778-
return model.Apply(name, args)
770+
return self._to_opaque().to_model()
779771

780772

781773
def _type_str(name: str, args: Sequence[TypeArg]) -> str:
@@ -826,7 +818,7 @@ def to_model(self) -> model.Term:
826818
# actual type or a row variable.
827819
args = [cast(model.Term, arg.to_model()) for arg in self.args]
828820

829-
return model.Apply(self.id, args)
821+
return model.Apply(f"{self.extension}.{self.id}", args)
830822

831823

832824
@dataclass

0 commit comments

Comments
 (0)