[Mlir-commits] [mlir] [MLIR][Python] MLIR Enum Python bindings infinite recursion (#151584) (PR #151588)

Nick Smith llvmlistbot at llvm.org
Fri Aug 8 09:45:15 PDT 2025


================
@@ -64,7 +64,7 @@ static void emitEnumClass(EnumInfo enumInfo, raw_ostream &os) {
   if (enumInfo.isBitEnum()) {
     os << formatv("    def __iter__(self):\n"
                   "        return iter([case for case in type(self) if "
-                  "(self & case) is case])\n");
+                  "(self & case) is case and self is not case])\n");
----------------
nsmithtt wrote:

This is the key part, do not allow iteration over exactly `self`'s bit value otherwise recursion ensues.

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


More information about the Mlir-commits mailing list