Closed drpriver closed 1 year ago
goBackToOpenParen can return size_t.max, which the calling code in getCalltipHint did not handle (and accidentally returns via an out parameter).
goBackToOpenParen
size_t.max
getCalltipHint
out
Check for this case so we don't get an array slice error.
Before this patch I would get a crash after typing the comma in code like this:
enum Foo { X, }
src/dcd/server/autocomplete/complete.d:366 pure nothrow @nogc @safe dcd.server.autocomplete.complete.CalltipHint dcd.server.autocomplete.complete.getCalltipHint!(std.range.SortedRange!(const(std.experimental.lexer.TokenStructure!(ubyte, "import dparse.lexer:TokenTriviaFields,TriviaToken; mixin TokenTriviaFields;").TokenStructure)[], "a < b", 0).SortedRange).getCalltipHint(std.range.SortedRange!(const(std.experimental.lexer.TokenStructure!(ubyte, "import dparse.lexer:TokenTriviaFields,TriviaToken; mixin TokenTriviaFields;").TokenStructure)[], "a < b", 0).SortedRange, out ulong) [0x1006ebf3f] src/dcd/server/autocomplete/complete.d:140 dcd.common.messages.AutocompleteResponse dcd.server.autocomplete.complete.complete(const(dcd.common.messages.AutocompleteRequest), ref dsymbol.modulecache.ModuleCache) [0x1006a812b] src/dcd/server/main.d:337 pure @nogc @safe dcd.common.messages.AutocompleteResponse dcd.server.main.runServer(immutable(char)[][]).__dgliteral66() [0x1006a777b] src/dcd/server/main.d:362 void dcd.server.main.trySendResponse(std.socket.Socket, lazy dcd.common.messages.AutocompleteResponse, lazy immutable(char)[]) [0x1006a6ecb] src/dcd/server/main.d:337 int dcd.server.main.runServer(immutable(char)[][]) [0x1006a46f3] src/dcd/server/main.d:63 _Dmain [0x1006a06a3]
Thanks for your Pull Request and making D better!
This comment will automatically be updated to summarize some statistics in a few minutes.
thanks! :)
goBackToOpenParen
can returnsize_t.max
, which the calling code ingetCalltipHint
did not handle (and accidentally returns via anout
parameter).Check for this case so we don't get an array slice error.
Before this patch I would get a crash after typing the comma in code like this: