RFC/PSA: confusing error messages

Inspired by an instance of this super ultra rare phenomenon, and the resulting discussion (on discord) with @mehdi_amini, I’m starting this thread to collect up all the confusing error messages people stumble over. This will serve the dual purposes of being a reference for the context/deeper meaning of those messages and a “staging ground” for patches, i.e., periodically (contingent on consensus) I’ll submit patches.

To start it off, this patch emends messages like this

[build] error: type of result #0, named '', is not buildable and a buildable type cannot be inferred

to

[build] error: type of result #0, named '', is not (default) buildable and a buildable type cannot be inferred

(note the added default) because (quoting mehdi):

You didn’t name the first result, and so it can’t be referenced in the assembly format. So the message is basically saying: “you want me to build the operation with a Foo_Float type, but I don’t know how to build one or infer it from the other informations, so you should specify it in the assembly format explicitly (or provide a way for it to be built”

3 Likes

I stumbled over one in the verifier for the linalg::YieldOp, when the number of yielded results is incorrect. Quoting from the tests, the (confusing / wrong) error message could look like this:

func.func @generic_mismatched_num_arguments(%arg0: memref<f32>) {
  // expected-error @+6 {{'linalg.yield' op expected number of yield values (2) to match the number of operands of the enclosing LinalgOp (1)}}
  linalg.generic {
      indexing_maps =  [ affine_map<() -> ()>, affine_map<() -> ()> ],
      iterator_types = []}
      outs(%arg0, %arg0 : memref<f32>, memref<f32>) {
    ^bb(%f: f32):
      linalg.yield %f: f32
  }
}

I think two things should be improved about this error message:

  1. The numbers given in round brackets are the wrong way around: The number of yield values and number of “operands” in the enclosing LinalgOp are switched.
  2. It says “the number of operands of the enclosing LinalgOp”, but what is meant is the number of inits/outs operands of the LinalgOp, not the number of overall operands.

I have prepared a revision to fix this error message and the corresponding tests: ⚙ D153124 [mlir][Linalg] Clarify error message in YieldOp verification NFC

1 Like