From 357c65f62b4905667585c0926585539d7f8c88d2 Mon Sep 17 00:00:00 2001 From: Hackerpilot Date: Sat, 17 Aug 2013 00:25:39 +0000 Subject: [PATCH] Fixed segfault with incomplete import statements --- acvisitor.d | 8 +++++--- build.sh | 2 +- client.d | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/acvisitor.d b/acvisitor.d index dc5779e..091e3fd 100644 --- a/acvisitor.d +++ b/acvisitor.d @@ -433,12 +433,14 @@ class AutocompleteVisitor : ASTVisitor { // TODO: handle public imports if (!currentFile) return; - foreach (singleImport; dec.singleImports) + foreach (singleImport; dec.singleImports.filter!(a => a !is null + && a.identifierChain !is null)) { scope_.symbols ~= ModuleCache.getSymbolsInModule( convertChainToImportPath(singleImport.identifierChain)); } - if (dec.importBindings !is null) + if (dec.importBindings !is null + && dec.importBindings.singleImport.identifierChain !is null) { scope_.symbols ~= ModuleCache.getSymbolsInModule( convertChainToImportPath( @@ -466,7 +468,7 @@ class AutocompleteVisitor : ASTVisitor private static string convertChainToImportPath(IdentifierChain chain) { - return to!string(chain.identifiers.map!"a.value"().join(dirSeparator).array) ~ ".d"; + return to!string(chain.identifiers.map!(a => a.value).join(dirSeparator).array) ~ ".d"; } ACSymbol[] symbols; diff --git a/build.sh b/build.sh index da57e14..0ae58bb 100755 --- a/build.sh +++ b/build.sh @@ -1,2 +1,2 @@ dmd -wi client.d messages.d msgpack-d/src/msgpack.d -Imsgpack-d/src -ofdcd-client -dmd -wi -g server.d modulecache.d actypes.d messages.d constants.d acvisitor.d autocomplete.d dscanner/stdx/d/ast.d dscanner/stdx/d/parser.d dscanner/stdx/d/lexer.d dscanner/stdx/d/entities.d msgpack-d/src/msgpack.d -Imsgpack-d/src -Idscanner/ -ofdcd-server +dmd -wi -g server.d modulecache.d actypes.d messages.d constants.d acvisitor.d autocomplete.d ../dscanner/stdx/d/ast.d ../dscanner/stdx/d/parser.d ../dscanner/stdx/d/lexer.d dscanner/stdx/d/entities.d msgpack-d/src/msgpack.d -Imsgpack-d/src -Idscanner/ -ofdcd-server diff --git a/client.d b/client.d index bb4e473..c3a8c0b 100644 --- a/client.d +++ b/client.d @@ -134,11 +134,11 @@ int main(string[] args) ubyte[] message = msgpack.pack(request); // Send message to server - auto socket = new TcpSocket(AddressFamily.INET); + TcpSocket socket = new TcpSocket(AddressFamily.INET); + socket.setOption(SocketOptionLevel.SOCKET, SocketOption.RCVTIMEO, dur!"seconds"(5)); scope (exit) { socket.shutdown(SocketShutdown.BOTH); socket.close(); } socket.connect(new InternetAddress("127.0.0.1", port)); socket.blocking = true; - //socket.setOption(SocketOptionLevel.TCP, SocketOption.TCP_NODELAY, 1); ubyte[] messageBuffer = new ubyte[message.length + message.length.sizeof]; auto messageLength = message.length; messageBuffer[0 .. 8] = (cast(ubyte*) &messageLength)[0 .. 8];