This commit is contained in:
Hackerpilot 2016-01-15 16:29:00 -08:00
parent f14c6e1226
commit 382258eb97
4 changed files with 26 additions and 3 deletions

View file

@ -949,8 +949,7 @@ private:
formatAt();
break;
case tok!"!":
if ((peekIs(tok!"is") || peekIs(tok!"in"))
&& !peekBackIsOneOf(false, tok!"(", tok!"="))
if ((peekIs(tok!"is") || peekIs(tok!"in")) && !peekBackIsOperator())
write(" ");
goto case;
case tok!"...":
@ -1488,7 +1487,7 @@ const pure @safe @nogc:
return peekImplementation(tokenType, -1, ignoreComments);
}
bool peekBackIsKeyword(bool ignoreComments = true)
bool peekBackIsKeyword(bool ignoreComments = true) pure nothrow const @nogc @safe
{
if (index == 0)
return false;
@ -1503,6 +1502,11 @@ const pure @safe @nogc:
return isKeyword(tokens[i].type);
}
bool peekBackIsOperator() pure nothrow const @nogc @safe
{
return index == 0 ? false : isOperator(tokens[index - 1].type);
}
bool peekBackIsOneOf(bool ignoreComments, IdType[] tokenTypes...)
{
if (index == 0)

View file

@ -0,0 +1,7 @@
unittest
{
if (a && !is(b == q))
{
}
}

7
tests/issue0208.d Normal file
View file

@ -0,0 +1,7 @@
unittest
{
if (a && !is(b == q))
{
}
}

View file

@ -0,0 +1,5 @@
unittest {
if (a && !is(b == q)) {
}
}