Don't write a space after the return attribute

Fixes #521.
This commit is contained in:
Eugen Wissner 2021-02-08 07:43:16 +01:00 committed by The Dlang Bot
parent e6199aaa9b
commit c4b6a7e7e3
4 changed files with 51 additions and 1 deletions

View file

@ -224,7 +224,9 @@ private:
else if (currentIs(tok!"return"))
{
writeToken();
if (!currentIs(tok!";") && !currentIs(tok!")") && !currentIs(tok!"{"))
if (!currentIs(tok!";") && !currentIs(tok!")") && !currentIs(tok!"{")
&& !currentIs(tok!"in") && !currentIs(tok!"out") && !currentIs(tok!"do")
&& (hasCurrent && tokens[index].text != "body"))
write(" ");
}
else if (currentIs(tok!"with"))

View file

@ -0,0 +1,17 @@
public int f() return
in (true)
{
return 0;
}
public int g() return
out (; true)
{
return 0;
}
public int h() return
body
{
return 0;
}

17
tests/issue0521.d Normal file
View file

@ -0,0 +1,17 @@
public int f() return
in (true)
{
return 0;
}
public int g() return
out (; true)
{
return 0;
}
public int h() return
body
{
return 0;
}

View file

@ -0,0 +1,14 @@
public int f() return
in (true) {
return 0;
}
public int g() return
out (; true) {
return 0;
}
public int h() return
body {
return 0;
}