diff --git a/mlir/lib/Interfaces/InferTypeOpInterface.cpp b/mlir/lib/Interfaces/InferTypeOpInterface.cpp --- a/mlir/lib/Interfaces/InferTypeOpInterface.cpp +++ b/mlir/lib/Interfaces/InferTypeOpInterface.cpp @@ -55,7 +55,9 @@ return failure(); if (!retTypeFn.isCompatibleReturnTypes(inferredReturnTypes, op->getResultTypes())) - return op->emitOpError( - "inferred type incompatible with return type of operation"); + return op->emitOpError("inferred type(s) ") + << inferredReturnTypes + << " are incompatible with return type(s) of operation " + << op->getResultTypes(); return success(); } diff --git a/mlir/test/mlir-tblgen/types.mlir b/mlir/test/mlir-tblgen/types.mlir --- a/mlir/test/mlir-tblgen/types.mlir +++ b/mlir/test/mlir-tblgen/types.mlir @@ -58,7 +58,7 @@ // ----- func @complex_f64_failure() { - // expected-error@+1 {{op inferred type incompatible with return type of operation}} + // expected-error@+1 {{op inferred type(s) 'complex' are incompatible with return type(s) of operation 'f64'}} "test.complex_f64"() : () -> (f64) return } @@ -438,7 +438,7 @@ // ----- func @same_types_element_mismatch(%arg0: tensor<* x i32>, %arg1: tensor<* x f32>) { - // expected-error@+1 {{type incompatible with return type of operation}} + // expected-error@+1 {{op inferred type(s) 'tensor<*xi32>' are incompatible with return type(s) of operation 'tensor<*xf32>'}} "test.operand0_and_result_have_same_type"(%arg0, %arg1) : (tensor<* x i32>, tensor<* x f32>) -> tensor<* x f32> return } @@ -446,7 +446,7 @@ // ----- func @same_types_shape_mismatch(%arg0: tensor<1x2xi32>, %arg1: tensor<2x1xi32>) { - // expected-error@+1 {{type incompatible with return type of operation}} + // expected-error@+1 {{op inferred type(s) 'tensor<1x2xi32>' are incompatible with return type(s) of operation 'tensor<2x1xi32>'}} "test.operand0_and_result_have_same_type"(%arg0, %arg1) : (tensor<1x2xi32>, tensor<2x1xi32>) -> tensor<2x1xi32> return }