Skip to content

Commit d42ed27

Browse files
committed
more coverage, fix range error in q"str
1 parent ad8a914 commit d42ed27

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/dparse/lexer.d

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,7 @@ private pure nothrow @safe:
14011401
{
14021402
Token ident;
14031403
lexIdentifier(ident);
1404-
if (isNewline())
1404+
if (!(range.index >= range.bytes.length) && isNewline())
14051405
popFrontWhitespaceAware();
14061406
else
14071407
error("Newline expected");
@@ -1426,14 +1426,15 @@ private pure nothrow @safe:
14261426
range.popFront();
14271427
}
14281428
}
1429+
IdType type;
14291430
if (!(range.index >= range.bytes.length) && range.bytes[range.index] == '"')
14301431
{
1432+
type = tok!"stringLiteral";
1433+
lexStringSuffix(type);
14311434
range.popFront();
14321435
}
14331436
else
14341437
error("`\"` expected");
1435-
IdType type = tok!"stringLiteral";
1436-
lexStringSuffix(type);
14371438
token = Token(type, cache.intern(range.slice(mark)), line, column, index);
14381439
}
14391440

@@ -2504,6 +2505,9 @@ void main() {
25042505

25052506
checkInvalidTrailingString(getTokensForParser(`x = "foo`, cf, &ca));
25062507
checkInvalidTrailingString(getTokensForParser(`x = r"foo`, cf, &ca));
2508+
checkInvalidTrailingString(getTokensForParser(`x = x"00`, cf, &ca));
25072509
checkInvalidTrailingString(getTokensForParser("x = `foo", cf, &ca));
25082510
checkInvalidTrailingString(getTokensForParser("x = q{foo", cf, &ca));
2511+
checkInvalidTrailingString(getTokensForParser(`x = q"foo`, cf, &ca));
2512+
checkInvalidTrailingString(getTokensForParser("x = '", cf, &ca));
25092513
}

0 commit comments

Comments
 (0)