diff --git a/mlir/lib/Tools/PDLL/Parser/Parser.cpp b/mlir/lib/Tools/PDLL/Parser/Parser.cpp --- a/mlir/lib/Tools/PDLL/Parser/Parser.cpp +++ b/mlir/lib/Tools/PDLL/Parser/Parser.cpp @@ -955,6 +955,12 @@ 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 --- a/mlir/test/mlir-pdll/Parser/constraint-failure.pdll +++ b/mlir/test/mlir-pdll/Parser/constraint-failure.pdll @@ -116,22 +116,22 @@ // ----- // 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 @@ // ----- // 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 @@ // CHECK: expected `;` after native declaration Constraint Foo() [{}] + +// ----- + +// CHECK: native Constraints currently do not support returning results +Constraint Foo() -> Op;