Fix out of bounds access in complete.d when there is no paren.

`goBackToOpenParen` can return size_t.max, which the calling code
in `getCalltipHint` did not handle (and accidentally returns via
an `out` parameter).

Check for this case so we don't get an array length error.
This commit is contained in:
drpriver 2023-09-30 15:40:21 -07:00
parent 8a693954d3
commit ed187e0c50
1 changed files with 6 additions and 1 deletions

View File

@ -361,7 +361,12 @@ CalltipHint getCalltipHint(T)(T beforeTokens, out size_t parenIndex)
// evaluate at comma case // evaluate at comma case
if (beforeTokens.isComma) if (beforeTokens.isComma)
{ {
parenIndex = beforeTokens.goBackToOpenParen; size_t tmp = beforeTokens.goBackToOpenParen;
if(tmp == size_t.max){
return CalltipHint.regularArguments;
}
parenIndex = tmp;
// check if we are actually a "!(" // check if we are actually a "!("
if (beforeTokens[0 .. parenIndex].isTemplateBangParen) if (beforeTokens[0 .. parenIndex].isTemplateBangParen)
{ {