<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/90404>90404</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [mlir] Generated method compiles in surprising manner
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            mlir:core
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          jpienaar
      </td>
    </tr>
</table>

<pre>
    For

```tablegen
def TableGenBuildOp6 : TEST_Op<"tblgen_build_6", [AttrSizedOperandSegments]> {
  let arguments = (ins Variadic<AnyType>:$a, Variadic<AnyType>:$b);
 let results = (outs AnyType:$result);
}
```

`builder.create<test::TableGenBuildOp6>(loc, ValueRange{*cstI32}, ValueRange{*cstI32})` calls into `void TableGenBuildOp6::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {})`. So the user expected to pass in two `ValueRange` (assuming that type inference was set on op) and instead got to path with a `TypeRange` (implicitly converted) and `ValueRange`. Now, the call site was wrong, but the error is rather confusing (compilation passes but fails at runtime - well if you are unlucky and `cstI32` actually had the same type as the op, then you get a valid operation with the correct type but wrong number of arguments, so runtime failure isn't even obvious).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8lEuP4jgQxz-NuZQaBQcCOeQATTPay7Q03dpry7EriWcdO7LLsOynX9mhH2JGI7UaP-rxr19VLELQvUVs2ObANseFiDQ43_ycNFoh_KJ16tqcnGfFkRX72_-qmP9ItAZ7tPOxwg5e08k3tIeojXqeKmDlHl6fXl7fnidWPjLOqTU92rc2GbxVjHPGH4FtDnsi_6L_Q_U8oRdWvWA_oqXANkdWPgHbHuYsAAYJhO9jvgZWHoHxnbYB_hZeC6UlKx_39vp6nZCVT6zcM74WKcsf7lvGa1a-p0gZPIZoPuO7SAE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