Skip to content

Commit

Permalink
more coverage, fix range error in q"str
Browse files Browse the repository at this point in the history
  • Loading branch information
WebFreak001 committed Feb 9, 2023
1 parent ad8a914 commit d42ed27
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/dparse/lexer.d
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,7 @@ private pure nothrow @safe:
{
Token ident;
lexIdentifier(ident);
if (isNewline())
if (!(range.index >= range.bytes.length) && isNewline())
popFrontWhitespaceAware();
else
error("Newline expected");
Expand All @@ -1426,14 +1426,15 @@ private pure nothrow @safe:
range.popFront();
}
}
IdType type;
if (!(range.index >= range.bytes.length) && range.bytes[range.index] == '"')
{
type = tok!"stringLiteral";
lexStringSuffix(type);
range.popFront();
}
else
error("`\"` expected");
IdType type = tok!"stringLiteral";
lexStringSuffix(type);
token = Token(type, cache.intern(range.slice(mark)), line, column, index);
}

Expand Down Expand Up @@ -2504,6 +2505,9 @@ void main() {

checkInvalidTrailingString(getTokensForParser(`x = "foo`, cf, &ca));
checkInvalidTrailingString(getTokensForParser(`x = r"foo`, cf, &ca));
checkInvalidTrailingString(getTokensForParser(`x = x"00`, cf, &ca));
checkInvalidTrailingString(getTokensForParser("x = `foo", cf, &ca));
checkInvalidTrailingString(getTokensForParser("x = q{foo", cf, &ca));
checkInvalidTrailingString(getTokensForParser(`x = q"foo`, cf, &ca));
checkInvalidTrailingString(getTokensForParser("x = '", cf, &ca));
}

0 comments on commit d42ed27

Please sign in to comment.