[Mlir-commits] [mlir] [MLIR] Improve verifier failure error message (PR #188507)
Mehdi Amini
llvmlistbot at llvm.org
Wed Mar 25 08:20:44 PDT 2026
https://github.com/joker-eph created https://github.com/llvm/llvm-project/pull/188507
None
>From 127ada0613fc0b8a0674e379121e8bcb082d4eb5 Mon Sep 17 00:00:00 2001
From: Mehdi Amini <joker.eph at gmail.com>
Date: Wed, 25 Mar 2026 08:19:17 -0700
Subject: [PATCH] [MLIR] Improve verifier failure error message
---
mlir/include/mlir/IR/OpImplementation.h | 3 ++-
mlir/test/IR/invalid-custom-print-parse.mlir | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
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>
More information about the Mlir-commits
mailing list