Skip to content

Commit 4b9aa5e

Browse files
authored
[spec/declaration] Improve docs (#3660)
Explain `Declaration` is the subset of DeclDef allowed inside a function body. Move TemplateMixin from DeclDef and NonEmptyStatementNoCaseNoDefault to Declaration (which they each include). Remove StaticAssert from DeclDef as it is already included by Declaration.
1 parent 93c7910 commit 4b9aa5e

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

spec/declaration.dd

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ $(HEADERNAV_TOC)
66

77
$(H2 $(LNAME2 grammar, Grammar))
88

9+
$(P *Declaration* can be used inside a function body for a $(GLINK2 statement, DeclarationStatement),
10+
as well as outside a function as it is included in $(GLINK2 module, DeclDef).)
11+
912
$(GRAMMAR
1013
$(GNAME Declaration):
1114
$(GLINK2 function, FuncDeclaration)
@@ -20,10 +23,9 @@ $(GNAME Declaration):
2023
$(GLINK2 version, StaticAssert)
2124
$(GLINK2 template, TemplateDeclaration)
2225
$(GLINK2 template-mixin, TemplateMixinDeclaration)
26+
$(GLINK2 template-mixin, TemplateMixin)
2327
)
2428

25-
$(P See also $(GLINK2 module, DeclDef).
26-
)
2729

2830
$(H3 $(LNAME2 aggregates, Aggregates))
2931

spec/module.dd

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ $(GNAME DeclDef):
3030
$(GLINK2 version, ConditionalDeclaration)
3131
$(GLINK2 version, DebugSpecification)
3232
$(GLINK2 version, VersionSpecification)
33-
$(GLINK2 version, StaticAssert)
34-
$(GLINK2 template-mixin, TemplateMixin)
3533
$(GLINK MixinDeclaration)
3634
$(GLINK EmptyDeclaration)
3735

@@ -629,19 +627,19 @@ $(P Each $(GLINK2 expression, AssignExpression) in the $(I ArgumentList) is
629627
evaluated at compile time, and the result must be representable
630628
as a string.
631629
The resulting strings are concatenated to form a string.
632-
The text contents of the string must be compilable as a valid
630+
The text contents of the string must be compilable as valid
633631
$(GLINK DeclDefs), and is compiled as such.)
634632

635-
$(P The content of a mixin cannot be forward referenced by other DeclDefs of
636-
the same scope because it is not yet pulled in the AST.)
633+
$(P The content of a mixin cannot be forward referenced by other *DeclDefs* of
634+
the same scope because it is not yet pulled into the AST.)
637635

638636
---------
639637
class B : A {} // Error: undefined identifier `A`
640638
mixin ("class A {}");
641639
---------
642640

643641
$(P Forward references may only work in function bodies because they
644-
are processed after the declarations)
642+
are processed after the declarations:)
645643

646644
---------
647645
void v()

spec/statement.dd

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,9 @@ $(GNAME NonEmptyStatementNoCaseNoDefault):
6363
$(GLINK2 pragma, PragmaStatement)
6464
$(GLINK2 version, ConditionalStatement)
6565
$(GLINK2 version, StaticForeachStatement)
66-
$(GLINK2 version, StaticAssert)
67-
$(GLINK2 template-mixin, TemplateMixin)
6866
$(GLINK2 module, ImportDeclaration)
6967
)
7068

71-
7269
$(P Any ambiguities in the grammar between $(I Statement)s and
7370
$(GLINK2 declaration, Declaration)s are
7471
resolved by the declarations taking precedence.

0 commit comments

Comments
 (0)