Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ArraySliceError in complete.d when there is no paren. #754

Merged
merged 1 commit into from
Sep 30, 2023

Conversation

drpriver
Copy link
Contributor

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 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]

`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.
@github-actions
Copy link

Thanks for your Pull Request and making D better!

This comment will automatically be updated to summarize some statistics in a few minutes.

@vushu vushu merged commit dc11cf7 into dlang-community:master Sep 30, 2023
1 check passed
@vushu
Copy link
Contributor

vushu commented Oct 1, 2023

thanks! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants