Expand ReturnOp error to include types. NFC.
authorJacques Pienaar <jpienaar@google.com>
Thu, 16 May 2019 21:12:18 +0000 (14:12 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Mon, 20 May 2019 20:44:42 +0000 (13:44 -0700)
    Found it a bit easier to see what mismatches occurred when invoking passes doesn't match.

--

PiperOrigin-RevId: 248597286

mlir/lib/StandardOps/Ops.cpp
mlir/test/IR/invalid.mlir

index 214d5a9..5d5f403 100644 (file)
@@ -1907,8 +1907,10 @@ static LogicalResult verify(ReturnOp op) {
 
   for (unsigned i = 0, e = results.size(); i != e; ++i)
     if (op.getOperand(i)->getType() != results[i])
-      return op.emitError("type of return operand ")
-             << i << " doesn't match function result type";
+      return op.emitError()
+             << "type of return operand " << i << " ("
+             << op.getOperand(i)->getType()
+             << ") doesn't match function result type (" << results[i] << ")";
 
   return success();
 }
index 0fe5029..39e8f27 100644 (file)
@@ -451,7 +451,7 @@ func @dominance_failure() {
 
 func @return_type_mismatch() -> i32 {
   %0 = "foo"() : ()->f32
-  return %0 : f32  // expected-error {{type of return operand 0 doesn't match function result type}}
+  return %0 : f32  // expected-error {{type of return operand 0 (f32) doesn't match function result type (i32)}}
 }
 
 // -----