Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions mlir/include/mlir/IR/OpImplementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -1603,10 +1603,12 @@ class OpAsmParser : public AsmParser {
SmallVectorImpl<Value> &result) {
size_t operandSize = llvm::range_size(operands);
size_t typeSize = llvm::range_size(types);
if (operandSize != typeSize)
return emitError(loc)
if (operandSize != typeSize) {
// If no location was provided, report errors at the beginning of the op.
return emitError(loc.isValid() ? loc : getNameLoc())
<< "number of operands and types do not match: got " << operandSize
<< " operands and " << typeSize << " types";
}

for (auto [operand, type] : llvm::zip_equal(operands, types))
if (resolveOperand(operand, type, result))
Expand Down
5 changes: 5 additions & 0 deletions mlir/test/IR/invalid-ops.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,8 @@ func.func @invalid_splat(%v : f32) { // expected-note {{prior use here}}

// expected-error@+1 {{expected ':' after block name}}
"g"()({^a:^b })

// -----

// expected-error@+1 {{number of operands and types do not match: got 0 operands and 1 types}}
test.variadic_args_types_split "hello_world" : i32
5 changes: 5 additions & 0 deletions mlir/test/lib/Dialect/Test/TestOpsSyntax.td
Original file line number Diff line number Diff line change
Expand Up @@ -767,4 +767,9 @@ def FormatInferTypeVariadicOperandsOp
}];
}

def VariadicArgsTypesSplit : TEST_Op<"variadic_args_types_split"> {
let arguments = (ins StrAttr:$str, Variadic<AnyType>:$args);
let assemblyFormat = "$str (`,` $args^)? attr-dict (`:` type($args)^)?";
}

#endif // TEST_OPS_SYNTAX