From 8ffdc48507692359991f9253466468392f3ba178 Mon Sep 17 00:00:00 2001 From: 0-v-0 Date: Tue, 7 Apr 2026 21:18:19 +0800 Subject: [PATCH 1/4] fix typo --- src/dparse/ast.d | 2 +- src/dparse/lexer.d | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dparse/ast.d b/src/dparse/ast.d index 35e287d7..b0177cb9 100644 --- a/src/dparse/ast.d +++ b/src/dparse/ast.d @@ -4203,7 +4203,7 @@ unittest // Differentiate between no and empty DDOC comments, e.g. for DDOC unit assert(visitor.found.length == 6); } -unittest // Support GCC-sytle asm statements +unittest // Support GCC-style asm statements { static void verify(T)(const string code, void function(scope const T) handler) { diff --git a/src/dparse/lexer.d b/src/dparse/lexer.d index 64713f9a..5f9b17e0 100644 --- a/src/dparse/lexer.d +++ b/src/dparse/lexer.d @@ -20,7 +20,7 @@ private immutable operators = [ "^=", "^^", "^^=", "{", "|", "|=", "||", "}", "~", "~=" ]; -/// Kewords +/// Keywords private immutable keywords = [ "abstract", "alias", "align", "asm", "assert", "auto", "bool", "break", "byte", "case", "cast", "catch", "cdouble", "cent", "cfloat", From 90638a2a3dc36881c206abbcf55a0582e6267914 Mon Sep 17 00:00:00 2001 From: 0-v-0 Date: Wed, 8 Apr 2026 15:45:15 +0800 Subject: [PATCH 2/4] Fix #523, support `align(default)` --- src/dparse/parser.d | 5 ++++- test/pass_files/issue0523.d | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 test/pass_files/issue0523.d diff --git a/src/dparse/parser.d b/src/dparse/parser.d index d2ba1c46..11148a77 100644 --- a/src/dparse/parser.d +++ b/src/dparse/parser.d @@ -312,7 +312,10 @@ class Parser if (currentIs(tok!"(")) { mixin(tokenCheck!"("); - mixin(parseNodeQ!("node.assignExpression", "AssignExpression")); + if (currentIs(tok!"default")) + advance(); + else + mixin(parseNodeQ!("node.assignExpression", "AssignExpression")); mixin(tokenCheck!")"); } node.tokens = tokens[startIndex .. index]; diff --git a/test/pass_files/issue0523.d b/test/pass_files/issue0523.d new file mode 100644 index 00000000..b8fc4398 --- /dev/null +++ b/test/pass_files/issue0523.d @@ -0,0 +1,16 @@ +struct S +{ + align(1) + { + short x1; + int y1; + long z1; + + align(default) + { + short x; + int y; + long z; + } + } +} From 9d9257d6fba109e058678aa7e7a50421d42e9d0c Mon Sep 17 00:00:00 2001 From: 0-v-0 Date: Sat, 11 Apr 2026 19:16:33 +0800 Subject: [PATCH 3/4] documentation update Co-authored-by: Jan Jurzitza --- src/dparse/parser.d | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/dparse/parser.d b/src/dparse/parser.d index 11148a77..2f947f15 100644 --- a/src/dparse/parser.d +++ b/src/dparse/parser.d @@ -300,7 +300,9 @@ class Parser * Parses an AlignAttribute. * * $(GRAMMAR $(RULEDEF alignAttribute): - * $(LITERAL 'align') ($(LITERAL '$(LPAREN)') $(RULE assignExpression) $(LITERAL '$(RPAREN)'))? + * $(LITERAL 'align') + * $(LITERAL 'align') $(LITERAL '$(LPAREN)') $(RULE assignExpression) $(LITERAL '$(RPAREN)') + * $(LITERAL 'align') $(LITERAL '$(LPAREN)') $(LITERAL 'default') $(LITERAL '$(RPAREN)') * ;) */ AlignAttribute parseAlignAttribute() From ebdf253d31ce8bf68d951773cdde7ce95cc71266 Mon Sep 17 00:00:00 2001 From: 0-v-0 Date: Sat, 11 Apr 2026 21:59:38 +0800 Subject: [PATCH 4/4] Add AlignAttribute.isExplicitDefault --- src/dparse/ast.d | 3 +++ src/dparse/formatter.d | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/dparse/ast.d b/src/dparse/ast.d index b0177cb9..5703fc16 100644 --- a/src/dparse/ast.d +++ b/src/dparse/ast.d @@ -612,6 +612,9 @@ final class AlignAttribute : BaseNode } mixin OpEquals; /** */ ExpressionNode assignExpression; + /** */ bool isExplicitDefault() inout @property @safe nothrow @nogc pure { + return tokens.length > 2 && tokens[2] == tok!"default"; + } } /// diff --git a/src/dparse/formatter.d b/src/dparse/formatter.d index 77217439..1d9d549c 100644 --- a/src/dparse/formatter.d +++ b/src/dparse/formatter.d @@ -206,7 +206,9 @@ class Formatter(Sink) **/ put("align"); - if (alignAttribute.assignExpression !is null) + if (alignAttribute.isExplicitDefault) + put("(default)"); + else if (alignAttribute.assignExpression !is null) { put("("); format(alignAttribute.assignExpression); @@ -4407,4 +4409,5 @@ z /// Documentation for z testFormatNode!(VariableDeclaration)("auto x = i` $(b) is $(b)!`;"); testFormatNode!(VariableDeclaration)("auto x = iq{ $(b) is $(b)!};"); testFormatNode!(VariableDeclaration)("auto x = iq{{$('$')}};"); + testFormatNode!(AlignAttribute)(`align(default) struct S {}`, `align(default)`); }