[Mlir-commits] [mlir] 1014eb2 - [mlir] Fix copy paste typo in convertFromAttribute (#192484)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Apr 17 02:58:20 PDT 2026


Author: Vincent
Date: 2026-04-17T09:58:15Z
New Revision: 1014eb28e7d4bbfe132b270d885cb9e094e4227a

URL: https://github.com/llvm/llvm-project/commit/1014eb28e7d4bbfe132b270d885cb9e094e4227a
DIFF: https://github.com/llvm/llvm-project/commit/1014eb28e7d4bbfe132b270d885cb9e094e4227a.diff

LOG: [mlir] Fix copy paste typo in convertFromAttribute (#192484)

It seems that the bool overload for `convertFromAttribute` has a failure
message incorrectly copied over from the string overload's
implementation.

Added: 
    mlir/test/IR/invalid-properties.mlir

Modified: 
    mlir/lib/IR/ODSSupport.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/IR/ODSSupport.cpp b/mlir/lib/IR/ODSSupport.cpp
index f2665d24efda6..de6139da84f1f 100644
--- a/mlir/lib/IR/ODSSupport.cpp
+++ b/mlir/lib/IR/ODSSupport.cpp
@@ -102,8 +102,7 @@ mlir::convertFromAttribute(bool &storage, Attribute attr,
                            function_ref<InFlightDiagnostic()> emitError) {
   auto valueAttr = dyn_cast<BoolAttr>(attr);
   if (!valueAttr)
-    return emitError()
-           << "expected string property to come from string attribute";
+    return emitError() << "expected BoolAttr for key `value`";
   storage = valueAttr.getValue();
   return success();
 }

diff  --git a/mlir/test/IR/invalid-properties.mlir b/mlir/test/IR/invalid-properties.mlir
new file mode 100644
index 0000000000000..4c9cdc3b1a692
--- /dev/null
+++ b/mlir/test/IR/invalid-properties.mlir
@@ -0,0 +1,49 @@
+// RUN: mlir-opt -verify-diagnostics -split-input-file %s
+
+
+// -----
+
+func.func @wrong_string_prop_type() {
+  // expected-error at +1 {{expected string property to come from string attribute}}
+  "test.with_properties"() <{b = "foo", c = 32 : i64}> : () -> ()
+  return
+}
+
+// -----
+
+func.func @wrong_bool_prop_type() {
+  // expected-error at +1 {{expected BoolAttr for key `value`}}
+  "test.with_properties"() <{b = "foo", flag = "bar"}> : () -> ()
+  return
+}
+
+// -----
+
+func.func @wrong_integer_prop_type() {
+  // expected-error at +1 {{expected IntegerAttr for key `value`}}
+  "test.with_properties"() <{b = "foo", a = "bar"}> : () -> ()
+  return
+}
+
+// -----
+
+func.func @wrong_dense_i64_array_prop_type() {
+  // expected-error at +1 {{expected DenseI64ArrayAttr for key `value`}}
+  "test.with_properties"() <{b = "foo", array = array<i32: 1, 2, 3, 4>}> : () -> ()
+  return
+}
+
+// -----
+
+func.func @wrong_dense_i32_array_prop_type() {
+  // expected-error at +1 {{expected DenseI32ArrayAttr for key `value`}}
+  "test.with_properties"() <{b = "foo", array32 = array<i64: 5, 6>}> : () -> ()
+  return
+}
+
+// -----
+
+func.func @valid_all_properties() {
+  "test.with_properties"() <{a = 32 : i64, array = array<i64: 1, 2, 3, 4>, array32 = array<i32: 5, 6>, b = "foo", c = "bar", flag = true}> : () -> ()
+  return
+}


        


More information about the Mlir-commits mailing list