[Mlir-commits] [mlir] [MLIR] Improve verifier failure error message (PR #188507)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Mar 25 08:21:23 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir-core

Author: Mehdi Amini (joker-eph)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/188507.diff


2 Files Affected:

- (modified) mlir/include/mlir/IR/OpImplementation.h (+2-1) 
- (modified) mlir/test/IR/invalid-custom-print-parse.mlir (+1-1) 


``````````diff
diff --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpImplementation.h
index 96c8f3d79c5e0..87b9e70bfbfb8 100644
--- a/mlir/include/mlir/IR/OpImplementation.h
+++ b/mlir/include/mlir/IR/OpImplementation.h
@@ -1172,7 +1172,8 @@ class AsmParser {
     result = dyn_cast<AttrType>(attr);
     if (!result)
       return emitError(getCurrentLocation())
-             << "expected attribute of a different type";
+             << "expected attribute of type '" << AttrType::name
+             << "', but found '" << attr << "'";
     return success();
   }
 
diff --git a/mlir/test/IR/invalid-custom-print-parse.mlir b/mlir/test/IR/invalid-custom-print-parse.mlir
index 41e8d97e1db49..5d623e1e0f235 100644
--- a/mlir/test/IR/invalid-custom-print-parse.mlir
+++ b/mlir/test/IR/invalid-custom-print-parse.mlir
@@ -29,7 +29,7 @@ test.op_with_enum_prop_attr_form <{value = 0 : i32, foo}>
 
 // Test that an integer literal cannot be used where an APFloat is expected.
 // parseOptionalAttribute(FloatAttr &) should reject a non-float attribute.
-// expected-error at +2 {{expected attribute of a different type}}
+// expected-error at +2 {{expected attribute of type 'builtin.float', but found '5 : i64'}}
 // expected-error at +1 {{failed to parse TestTypeAPFloat parameter}}
 func.func private @test_ap_float_wrong_attr_type() -> !test.ap_float<5U0>
 

``````````

</details>


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


More information about the Mlir-commits mailing list