dfmt
dfmt copied to clipboard
Anonymous function in struct breaks indentation
Input:
import std.stdio : writeln;
struct S {
ulong x;
ulong y;
ulong function(ulong) f;
}
immutable S s = {
1111111111111111111,
1111111111111111111,
(x) {
return x + 1111;
},
};
void main() {
writeln(s.f(1));
}
Output:
import std.stdio : writeln;
struct S
{
ulong x;
ulong y;
ulong function(ulong) f;
}
immutable S s = {
1111111111111111111, 1111111111111111111, (x) { return x + 1111; },};
void main()
{
writeln(s.f(1));
}
It looks like an anonymous function and a long struct initializer are needed, but there doesn't need to be nesting:
import std.stdio : writeln;
struct S {
ulong x;
ulong y;
ulong z;
ulong w;
}
immutable int function(int) f = (x) {
return x + 1111;
};
immutable S s = {
1111111111111111111,
1111111111111111111,
1111111111111111111,
1111111111111111111,
};
void main() {
}
becomes:
struct S
{
ulong x;
ulong y;
ulong z;
ulong w;
}
immutable int function(int) f = (x) { return x + 1111; };
immutable S s = {
1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111,};
void main()
{
}
fixed in #590