Merge pull request #5657 from DmitryOlshansky/issue-17668

Fix issue 17668 - assert failure regex(q"<[^]>")
merged-on-behalf-of: Dmitry Olshansky <DmitryOlshansky@users.noreply.github.com>
This commit is contained in:
The Dlang Bot 2017-08-07 13:12:33 +02:00 committed by GitHub
commit bcb17a6d88
2 changed files with 9 additions and 0 deletions

View file

@ -1304,6 +1304,7 @@ if (isForwardRange!R && is(ElementType!R : dchar))
switch (op)
{
case Operator.Negate:
enforce(!stack.empty, "no operand for '^'");
stack.top = stack.top.inverted;
break;
case Operator.Union:

View file

@ -1098,3 +1098,11 @@ alias Sequence(int B, int E) = staticIota!(B, E);
willThrow([r"[a-\", r"123"], "invalid escape sequence");
willThrow([r"\", r"123"], "invalid escape sequence");
}
// bugzilla 17668
@safe unittest
{
import std.algorithm.searching;
auto e = collectException!RegexException(regex(q"<[^]>"));
assert(e.msg.canFind("no operand for '^'"));
}