diff --git a/mlir/lib/Parser/AttributeParser.cpp b/mlir/lib/Parser/AttributeParser.cpp --- a/mlir/lib/Parser/AttributeParser.cpp +++ b/mlir/lib/Parser/AttributeParser.cpp @@ -841,6 +841,9 @@ return (emitError("expected dialect namespace"), nullptr); std::string name = getToken().getStringValue(); + if (!Dialect::isValidNamespace(name)) + return (emitError() << "invalid dialect namespace '" << name << "'", + nullptr); consumeToken(Token::string); if (parseToken(Token::comma, "expected ','")) diff --git a/mlir/test/IR/attribute.mlir b/mlir/test/IR/attribute.mlir --- a/mlir/test/IR/attribute.mlir +++ b/mlir/test/IR/attribute.mlir @@ -645,3 +645,7 @@ return } +// ----- + +// expected-error @+1 {{invalid dialect namespace 'string with space'}} +#invalid_dialect = opaque<"string with space", "0xDEADBEEF"> : i32