diff --git a/hugr-py/src/hugr/std/int.py b/hugr-py/src/hugr/std/int.py index 67e7137d8..722fd3c24 100644 --- a/hugr-py/src/hugr/std/int.py +++ b/hugr-py/src/hugr/std/int.py @@ -2,7 +2,7 @@ from __future__ import annotations -from dataclasses import dataclass +from dataclasses import dataclass, field from typing import TYPE_CHECKING, ClassVar from typing_extensions import Self @@ -15,7 +15,7 @@ def int_t(width: int) -> tys.Opaque: - """Create an integer type with a given log bit width. + """Create an integer type with a fixed log bit width. Args: @@ -45,9 +45,10 @@ class IntVal(val.ExtensionValue): """Custom value for an integer.""" v: int + width: int = field(default=5) def to_value(self) -> val.Extension: - return val.Extension("int", INT_T, self.v) + return val.Extension("int", int_t(self.width), self.v) OPS_EXTENSION: tys.ExtensionId = "arithmetic.int"