diff --git a/tools/tidy/include/ASTHelperVisitors.h b/tools/tidy/include/ASTHelperVisitors.h index f0cb45aa5..b5c7cbc80 100644 --- a/tools/tidy/include/ASTHelperVisitors.h +++ b/tools/tidy/include/ASTHelperVisitors.h @@ -55,7 +55,8 @@ struct CollectIdentifiers : public slang::ast::ASTVisitor { void handle(const slang::ast::AssignmentExpression& expression) { - symbols.push_back(expression.left().getSymbolReference()); + if (const auto symbol = expression.left().getSymbolReference(); symbol) + symbols.push_back(symbol); } std::vector symbols; diff --git a/tools/tidy/tests/NoOldAlwaysSyntaxTest.cpp b/tools/tidy/tests/NoOldAlwaysSyntaxTest.cpp index 00c7d340d..ba98eaa1c 100644 --- a/tools/tidy/tests/NoOldAlwaysSyntaxTest.cpp +++ b/tools/tidy/tests/NoOldAlwaysSyntaxTest.cpp @@ -199,3 +199,27 @@ endmodule bool result = visitor->check(root); CHECK(result); } + +TEST_CASE("NoOldAlwaysSyntax: composite lhs") { + auto tree = SyntaxTree::fromText(R"( +module top(); + logic n; + + always @(*) begin + {n} = 1; + end +endmodule +)"); + + Compilation compilation; + compilation.addSyntaxTree(tree); + compilation.getAllDiagnostics(); + auto& root = compilation.getRoot(); + + TidyConfig config; + Registry::setConfig(config); + Registry::setSourceManager(compilation.getSourceManager()); + auto visitor = Registry::create("NoOldAlwaysSyntax"); + bool result = visitor->check(root); + CHECK(result); +}