Fix crash when function returns auto

This commit is contained in:
RUSshy 2021-08-31 16:52:21 +02:00 committed by GitHub
parent d5bc235309
commit 9c0b2d60c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 3 deletions

View File

@ -770,9 +770,19 @@ AutocompleteResponse.Completion makeSymbolCompletionInfo(const DSymbol* symbol,
//
// TODO: should probably move it at the call site
// TODO: should probably make it fully recursive,
if(s.type && s.type.kind == CompletionKind.functionName) s = s.type;
definition = s.name ~ ' ' ~ symbol.name;
if (symbol.type.kind == CompletionKind.functionName && symbol.type.type)
{
// if can resolve the function's type, that means it is a known type and not return auto
const(DSymbol)* resolved = symbol.type.type;
if (resolved.type)
definition = resolved.type.name ~ ' ' ~ symbol.name;
else
definition = resolved.name ~ ' ' ~ symbol.name;
}
else
{
definition = symbol.type.name ~ ' ' ~ symbol.name;
}
}
else if (kind == CompletionKind.enumMember)
definition = symbol.name; // TODO: add enum value to definition string