Emit an error when parsing an affine structure if '->' or ':' is not found
after the dim/symbol id list.

PiperOrigin-RevId: 232094789
diff --git a/lib/Parser/Parser.cpp b/lib/Parser/Parser.cpp
index a9c6276..44587cb 100644
--- a/lib/Parser/Parser.cpp
+++ b/lib/Parser/Parser.cpp
@@ -1943,7 +1943,7 @@
   bool isArrow = getToken().is(Token::arrow);
   bool isColon = getToken().is(Token::colon);
   if (!isArrow && !isColon) {
-    return ParseFailure;
+    return emitError("expected '->' or ':'");
   } else if (isArrow) {
     parseToken(Token::arrow, "expected '->' or '['");
     map = parseAffineMapRange(numDims, numSymbols);
diff --git a/test/IR/invalid.mlir b/test/IR/invalid.mlir
index e41f88c..110b374 100644
--- a/test/IR/invalid.mlir
+++ b/test/IR/invalid.mlir
@@ -803,3 +803,11 @@
 // -----
 
 #set_without_constraints = (i, j) : () // expected-error {{expected a valid affine constraint}}
+
+// -----
+
+func @invalid_affine_structure() {
+  %c0 = constant 0 : index
+  %idx = affine_apply (d0, d1) (%c0, %c0) // expected-error {{expected '->' or ':'}}
+  return
+}