fix #584 - crash when completing and if the previous expression is negated (#586)

fix #584 - crash when completing and if the previous expression is negated
merged-on-behalf-of: Basile-z <Basile-z@users.noreply.github.com>
This commit is contained in:
Basile-z 2019-02-18 06:41:21 +01:00 committed by The Dlang Bot
parent 8a7a6c75ac
commit cb0e49bc36
5 changed files with 40 additions and 4 deletions

View File

@ -189,9 +189,12 @@ DSymbol*[] getSymbolsByTokenChain(T)(Scope* completionScope,
{ {
size_t j; size_t j;
tokens.skipParen(j, tok!"(", tok!")"); tokens.skipParen(j, tok!"(", tok!")");
if (j > 1)
{
symbols = getSymbolsByTokenChain(completionScope, tokens[1 .. j], symbols = getSymbolsByTokenChain(completionScope, tokens[1 .. j],
cursorPosition, completionType); cursorPosition, completionType);
tokens = tokens[j + 1 .. $]; tokens = tokens[j + 1 .. $];
}
//writeln("<<<"); //writeln("<<<");
//dumpTokens(tokens.release); //dumpTokens(tokens.release);
//writeln("<<<"); //writeln("<<<");
@ -514,12 +517,14 @@ T getExpression(T)(T beforeTokens)
i = bookmark + 1; i = bookmark + 1;
break expressionLoop; break expressionLoop;
case tok!"!": case tok!"!":
if (skipCount == 1) // only break if the bang is for a template instance
if (i - 2 >= 0 && beforeTokens[i - 2].type == tok!"identifier" && skipCount == 1)
{ {
sliceEnd = i - 1; sliceEnd = i - 1;
i -= 2; i -= 2;
}
break expressionLoop; break expressionLoop;
}
break;
default: default:
break; break;
} }

View File

@ -0,0 +1,8 @@
identifiers
alignof k
init k
mangleof k
max k
min k
sizeof k
stringof k

View File

@ -0,0 +1,9 @@
identifiers
T h
alignof k
i v
init k
mangleof k
sizeof k
stringof k
tupleof k

View File

@ -0,0 +1,7 @@
void main()
{
char[][] a;
if (!(a[0][0]). ){}
template Foo(T) { int i;}
if (Foo!(int). ){}
}

View File

@ -0,0 +1,7 @@
set -e
set -u
../../bin/dcd-client $1 file.d -c49 > actual1.txt
diff actual1.txt expected1.txt
../../bin/dcd-client $1 file.d -c103 > actual2.txt
diff actual2.txt expected2.txt