diff --git a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp --- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp +++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp @@ -622,8 +622,12 @@ return emitOpError("incorrect number of results for callee"); for (unsigned i = 0, e = fnType.getNumResults(); i != e; ++i) - if (getResult(i).getType() != fnType.getResult(i)) - return emitOpError("result type mismatch"); + if (getResult(i).getType() != fnType.getResult(i)) { + auto diag = emitOpError("result type mismatch at index ") << i; + diag.attachNote() << " op result types: " << getResultTypes(); + diag.attachNote() << "function result types: " << fnType.getResults(); + return diag; + } return success(); } diff --git a/mlir/test/Dialect/Standard/invalid.mlir b/mlir/test/Dialect/Standard/invalid.mlir --- a/mlir/test/Dialect/Standard/invalid.mlir +++ b/mlir/test/Dialect/Standard/invalid.mlir @@ -69,3 +69,19 @@ %0 = constant [1.0 : f32, -1.0 : f64] : complex return } + +// ----- + +func @return_i32_f32() -> (i32, f32) { + %0 = constant 1 : i32 + %1 = constant 1. : f32 + return %0, %1 : i32, f32 +} + +func @call() { + // expected-error @+3 {{op result type mismatch at index 0}} + // expected-note @+2 {{op result types: 'f32', 'i32'}} + // expected-note @+1 {{function result types: 'i32', 'f32'}} + %0:2 = call @return_i32_f32() : () -> (f32, i32) + return +}