From 089a60266f2658e471d204fdd737e3e0d37e105c Mon Sep 17 00:00:00 2001 From: Andres Noetzli Date: Thu, 19 Mar 2020 07:18:58 -0700 Subject: Only apply testConstStringInRegExp to const regexp (#4120) Fixes #4070. `TheoryStringsRewriter::rewriteConcatRegExp()` rewrites `(a)* ++ (_)*` to `(_)*`. To do so, it checks whether the elements preceding `(_)*` match the empty string using `TheoryStringsRewriter::testConstStringInRegExp()`. However, this method only expects to be called on constant regular expressions (i.e. regular expressions without string variables). This commit adds a corresponding check before calling `TheoryStringsRewriter::testConstStringInRegExp()`. --- src/theory/strings/theory_strings_rewriter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/theory/strings') diff --git a/src/theory/strings/theory_strings_rewriter.cpp b/src/theory/strings/theory_strings_rewriter.cpp index f05c9165b..95f537878 100644 --- a/src/theory/strings/theory_strings_rewriter.cpp +++ b/src/theory/strings/theory_strings_rewriter.cpp @@ -907,7 +907,7 @@ Node TheoryStringsRewriter::rewriteConcatRegExp(TNode node) { // if empty, drop it // e.g. this ensures we rewrite (_)* ++ (a)* ---> (_)* - if (testConstStringInRegExp(emptyStr, 0, curr)) + if (isConstRegExp(curr) && testConstStringInRegExp(emptyStr, 0, curr)) { curr = Node::null(); } @@ -928,7 +928,7 @@ Node TheoryStringsRewriter::rewriteConcatRegExp(TNode node) lastAllStar = true; // go back and remove empty ones from back of cvec // e.g. this ensures we rewrite (a)* ++ (_)* ---> (_)* - while (!cvec.empty() + while (!cvec.empty() && isConstRegExp(cvec.back()) && testConstStringInRegExp(emptyStr, 0, cvec.back())) { cvec.pop_back(); -- cgit v1.2.3