From d40abbedd45fe1115ccbb3ccca46ed95608ba698 Mon Sep 17 00:00:00 2001 From: Yan Churkin Date: Sat, 5 Oct 2024 18:57:40 +0300 Subject: [PATCH] [bug][slang] Fix recursive property negation check bug --- source/ast/expressions/MiscExpressions.cpp | 4 +++- tests/unittests/ast/AssertionTests.cpp | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/source/ast/expressions/MiscExpressions.cpp b/source/ast/expressions/MiscExpressions.cpp index 1f6a25a54..a9fcba7b5 100644 --- a/source/ast/expressions/MiscExpressions.cpp +++ b/source/ast/expressions/MiscExpressions.cpp @@ -1005,9 +1005,11 @@ Expression& AssertionInstanceExpression::fromLookup(const Symbol& symbol, ASTContext bodyContext(*symbolScope, LookupLocation::max); bodyContext.assertionInstance = &instance; - // Propagate previously founded time advance specs + // Propagate previously founded time advance specs and negation operators if (context.flags.has(ASTFlags::PropertyTimeAdvance)) bodyContext.flags |= ASTFlags::PropertyTimeAdvance; + if (context.flags.has(ASTFlags::PropertyNegation)) + bodyContext.flags |= ASTFlags::PropertyNegation; // Let declarations expand directly to an expression. if (symbol.kind == SymbolKind::LetDecl) diff --git a/tests/unittests/ast/AssertionTests.cpp b/tests/unittests/ast/AssertionTests.cpp index 320575323..b8577ebd3 100644 --- a/tests/unittests/ast/AssertionTests.cpp +++ b/tests/unittests/ast/AssertionTests.cpp @@ -1119,13 +1119,14 @@ endmodule compilation.addSyntaxTree(tree); auto& diags = compilation.getAllDiagnostics(); - REQUIRE(diags.size() == 6); + REQUIRE(diags.size() == 7); CHECK(diags[0].code == diag::RecursivePropNegation); - CHECK(diags[1].code == diag::RecursivePropDisableIff); - CHECK(diags[2].code == diag::RecursivePropTimeAdvance); - CHECK(diags[3].code == diag::RecursivePropArgExpr); + CHECK(diags[1].code == diag::RecursivePropNegation); + CHECK(diags[2].code == diag::RecursivePropDisableIff); + CHECK(diags[3].code == diag::RecursivePropTimeAdvance); CHECK(diags[4].code == diag::RecursivePropArgExpr); CHECK(diags[5].code == diag::RecursivePropArgExpr); + CHECK(diags[6].code == diag::RecursivePropArgExpr); } TEST_CASE("Illegal concurrent assertions in action blocks") {