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

Rolf Morel llvmlistbot at llvm.org
Wed Mar 25 13:01:16 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:

> the separation between types and attributes is an MLIR implementation detail

Just wanted to point out that this is _not_ the case for MLIR proper (versus e.g. xDSL). The type hierarchies are disjoint and (all?) user-facing APIs are such that you need to pass one or the other. That the way to interact with types and attributes (unique-ing in the context) is very similar is the implementation detail.

The change in this PR demonstrates that this violates typing consistency. Making type inference nigh impossible. As the IRDL dialect is essentially untyped, I guess the issue doesn't crop up there.

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


More information about the Mlir-commits mailing list