[Mlir-commits] [mlir] [MLIR][IRDL][Python] Fix error while composing `irdl.any_of` and `irdl.base` (PR #187914)

Rolf Morel llvmlistbot at llvm.org
Sun Mar 22 17:16:23 PDT 2026


================
@@ -736,3 +736,44 @@ class AssignNoneOnNonOptionalOp(
     except ValueError as e:
         # CHECK: only optional operand can be a keyword parameter
         print(e)
+
+
+# CHECK: TEST: testExtDialectWithAttrInOp
+ at run
+def testExtDialectWithAttrInOp():
+    class TestAttrInOp(Dialect, name="ext_attr_in_op"):
+        pass
+
+    class OpWithAttr(TestAttrInOp.Operation, name="op_with_attr"):
+        a: IntegerAttr | StringAttr
+        b: IntegerType[32] | IntegerType[64]
----------------
rolfmorel wrote:

Do we allow fields of ops to be `ir.Type`s? I guess this is due to IRDL allowing Values which refer to types which are subsequently used in an attributes dict.

I find it a bit surprising that the constructor takes `b` at attribute type. Or rather, it would be less surprising if we would instead write `b: TypeAttr[IntegerType[32] | IntegerType[64]]` and `b` would need to indeed be of `TypeAttr` type in the constructor.

I think we would have little hope for `dataclass_transform` working out if we weren't to insist on something like this.

https://github.com/llvm/llvm-project/pull/187914


More information about the Mlir-commits mailing list