summaryrefslogtreecommitdiff
path: root/src/theory/strings
diff options
context:
space:
mode:
authorAndres Noetzli <andres.noetzli@gmail.com>2020-03-19 07:18:58 -0700
committerGitHub <noreply@github.com>2020-03-19 09:18:58 -0500
commit089a60266f2658e471d204fdd737e3e0d37e105c (patch)
treedd07799cf5a1a06f184ce402fab016bf54c656e0 /src/theory/strings
parent94844fbf4fbe4fa08d8fa4cbe093ba532f5bd613 (diff)
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()`.
Diffstat (limited to 'src/theory/strings')
-rw-r--r--src/theory/strings/theory_strings_rewriter.cpp4
1 files changed, 2 insertions, 2 deletions
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();
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback