Skip to content

Commit c4b6a7e

Browse files
belka-ewdlang-bot
authored andcommitted
Don't write a space after the return attribute
Fixes #521.
1 parent e6199aa commit c4b6a7e

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed

src/dfmt/formatter.d

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ private:
224224
else if (currentIs(tok!"return"))
225225
{
226226
writeToken();
227-
if (!currentIs(tok!";") && !currentIs(tok!")") && !currentIs(tok!"{"))
227+
if (!currentIs(tok!";") && !currentIs(tok!")") && !currentIs(tok!"{")
228+
&& !currentIs(tok!"in") && !currentIs(tok!"out") && !currentIs(tok!"do")
229+
&& (hasCurrent && tokens[index].text != "body"))
228230
write(" ");
229231
}
230232
else if (currentIs(tok!"with"))

tests/allman/issue0521.d.ref

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
public int f() return
2+
in (true)
3+
{
4+
return 0;
5+
}
6+
7+
public int g() return
8+
out (; true)
9+
{
10+
return 0;
11+
}
12+
13+
public int h() return
14+
body
15+
{
16+
return 0;
17+
}

tests/issue0521.d

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
public int f() return
2+
in (true)
3+
{
4+
return 0;
5+
}
6+
7+
public int g() return
8+
out (; true)
9+
{
10+
return 0;
11+
}
12+
13+
public int h() return
14+
body
15+
{
16+
return 0;
17+
}

tests/otbs/issue0521.d.ref

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
public int f() return
2+
in (true) {
3+
return 0;
4+
}
5+
6+
public int g() return
7+
out (; true) {
8+
return 0;
9+
}
10+
11+
public int h() return
12+
body {
13+
return 0;
14+
}

0 commit comments

Comments
 (0)