Skip to content

Commit

Permalink
[slang][parser] Fix timeless constraint expression parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Yan Churkin committed Sep 17, 2024
1 parent d077ed8 commit c0feaa5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 0 additions & 2 deletions source/syntax/SyntaxFacts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,6 @@ bool SyntaxFacts::isPossibleExpression(TokenKind kind) {
// to provide good error handling
case TokenKind::DoubleColon:
case TokenKind::Question:
case TokenKind::MatchesKeyword:
case TokenKind::TripleAnd:
case TokenKind::InsideKeyword:
case TokenKind::DistKeyword:
return true;
Expand Down
12 changes: 12 additions & 0 deletions tests/unittests/parsing/MemberParsingTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1489,3 +1489,15 @@ endmodule
REQUIRE(diagnostics.size() == 1);
CHECK(diagnostics[0].code == diag::UnexpectedEndDelim);
}

TEST_CASE("Bad top level constraints") {
auto& text = R"(
constraint A :: A { &&& }
constraint A :: A { matches }
)";
parseCompilationUnit(text);

REQUIRE(diagnostics.size() == 2);
CHECK(diagnostics[0].code == diag::ExpectedMember);
CHECK(diagnostics[1].code == diag::ExpectedMember);
}

0 comments on commit c0feaa5

Please sign in to comment.