diff --git a/mlir/lib/Tools/PDLL/Parser/Parser.cpp b/mlir/lib/Tools/PDLL/Parser/Parser.cpp index e69e8ff7e1944f..da7283799d951c 100644 --- a/mlir/lib/Tools/PDLL/Parser/Parser.cpp +++ b/mlir/lib/Tools/PDLL/Parser/Parser.cpp @@ -955,6 +955,12 @@ FailureOr Parser::parseUserNativeConstraintOrRewriteDecl( if (failed(parseToken(Token::semicolon, "expected `;` after native declaration"))) return failure(); + // TODO: PDL should be able to support constraint results in certain + // situations, we should revise this. + if (std::is_same::value && !results.empty()) { + return emitError( + "native Constraints currently do not support returning results"); + } return T::createNative(ctx, name, arguments, results, optCodeStr, resultType); } diff --git a/mlir/test/mlir-pdll/Parser/constraint-failure.pdll b/mlir/test/mlir-pdll/Parser/constraint-failure.pdll index 82919136239438..18877b4bcc50ec 100644 --- a/mlir/test/mlir-pdll/Parser/constraint-failure.pdll +++ b/mlir/test/mlir-pdll/Parser/constraint-failure.pdll @@ -116,22 +116,22 @@ Constraint Foo() -> {} // ----- // CHECK: cannot create a single-element tuple with an element label -Constraint Foo() -> result: Value; +Constraint Foo() -> result: Value {} // ----- // CHECK: cannot create a single-element tuple with an element label -Constraint Foo() -> (result: Value); +Constraint Foo() -> (result: Value) {} // ----- // CHECK: expected identifier constraint -Constraint Foo() -> (); +Constraint Foo() -> () {} // ----- // CHECK: expected `:` before result constraint -Constraint Foo() -> (result{}; +Constraint Foo() -> (result {}; // ----- @@ -141,7 +141,7 @@ Constraint Foo() -> (Op{}; // ----- // CHECK: inline `Attr`, `Value`, and `ValueRange` type constraints are not permitted on arguments or results -Constraint Foo() -> Value){} +Constraint Foo() -> Value) {} // ----- @@ -158,3 +158,8 @@ Pattern { // CHECK: expected `;` after native declaration Constraint Foo() [{}] + +// ----- + +// CHECK: native Constraints currently do not support returning results +Constraint Foo() -> Op;