Skip to content

Commit 1822eb0

Browse files
0-v-0WebFreak001
authored andcommitted
Add AlignAttribute.isExplicitDefault
1 parent 97dcbcb commit 1822eb0

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/dparse/ast.d

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,9 @@ final class AlignAttribute : BaseNode
612612
}
613613
mixin OpEquals;
614614
/** */ ExpressionNode assignExpression;
615+
/** */ bool isExplicitDefault() inout @property @safe nothrow @nogc pure {
616+
return tokens.length > 2 && tokens[2] == tok!"default";
617+
}
615618
}
616619

617620
///

src/dparse/formatter.d

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ class Formatter(Sink)
206206
**/
207207

208208
put("align");
209-
if (alignAttribute.assignExpression !is null)
209+
if (alignAttribute.isExplicitDefault)
210+
put("(default)");
211+
else if (alignAttribute.assignExpression !is null)
210212
{
211213
put("(");
212214
format(alignAttribute.assignExpression);
@@ -4407,4 +4409,5 @@ z /// Documentation for z
44074409
testFormatNode!(VariableDeclaration)("auto x = i` $(b) is $(b)!`;");
44084410
testFormatNode!(VariableDeclaration)("auto x = iq{ $(b) is $(b)!};");
44094411
testFormatNode!(VariableDeclaration)("auto x = iq{{$('$')}};");
4412+
testFormatNode!(AlignAttribute)(`align(default) struct S {}`, `align(default)`);
44104413
}

0 commit comments

Comments
 (0)