Skip to content

Commit 8548a7d

Browse files
Fixed issue 22348 - Specify forward referencing of MixinDeclaration (#3513)
* Fixed issue 22348 - Specify forward referencing of MixinDeclaration Signed-off-by: Robert Grancsa <[email protected]> * fixed indentation Signed-off-by: Robert Grancsa <[email protected]> * fixed indentation Signed-off-by: Robert Grancsa <[email protected]> * fixed indentation Signed-off-by: Robert Grancsa <[email protected]> * Fix Issue 22348 - Specify forward referencing of MixinDeclaration Signed-off-by: Robert Grancsa <[email protected]> --------- Signed-off-by: Robert Grancsa <[email protected]>
1 parent e35bcfa commit 8548a7d

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

spec/module.dd

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -626,14 +626,31 @@ $(GNAME MixinDeclaration):
626626
$(D mixin) $(D $(LPAREN)) $(GLINK2 expression, ArgumentList) $(D $(RPAREN)) $(D ;)
627627
)
628628

629-
$(P Each $(GLINK2 expression, AssignExpression) in the $(I ArgumentList) is
630-
evaluated at compile time, and the result must be representable
631-
as a string.
632-
The resulting strings are concatenated to form a string.
633-
The text contents of the string must be compilable as a valid
634-
$(GLINK DeclDefs), and is compiled as such.
635-
)
629+
$(P Each $(GLINK2 expression, AssignExpression) in the $(I ArgumentList) is
630+
evaluated at compile time, and the result must be representable
631+
as a string.
632+
The resulting strings are concatenated to form a string.
633+
The text contents of the string must be compilable as a valid
634+
$(GLINK DeclDefs), and is compiled as such.)
636635

636+
$(P The content of a mixin cannot be forward referenced by other DeclDefs of
637+
the same scope because it is not yet pulled in the AST.)
638+
639+
---------
640+
class B : A {} // Error: undefined identifier `A`
641+
mixin ("class A {}");
642+
---------
643+
644+
$(P Forward references may only work in function bodies because they
645+
are processed after the declarations)
646+
647+
---------
648+
void v()
649+
{
650+
class B : A {}
651+
}
652+
mixin ("class A {}");
653+
---------
637654

638655
$(H2 $(LEGACY_LNAME2 PackageModule, package-module, Package Module))
639656

0 commit comments

Comments
 (0)