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 @@ -1205,10 +1205,9 @@ return op.emitOpError() << "requires attribute's type (" << value.getType() << ") to match op's return type (" << type << ")"; - if (type.isa() || value.isa()) - return success(); - if (auto intAttr = value.dyn_cast()) { + if (type.isa() || value.isa()) + return success(); IntegerType intType = type.cast(); if (!intType.isSignless()) return op.emitOpError("requires integer result types to be signless"); 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 @@ -247,3 +247,11 @@ %0 = constant 0 : si32 return } + +// ----- + +func @unsupported_attribute() { + // expected-error @+1 {{unsupported 'value' attribute: "" : index}} + %0 = constant "" : index + return +}