From 6d2efeaca56049b85d4e418f0e735454b8e0000c Mon Sep 17 00:00:00 2001 From: "Quirin F. Schroll" Date: Tue, 25 Oct 2022 16:00:17 +0200 Subject: [PATCH 01/16] Fix Issue 2753 --- spec/type.dd | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/type.dd b/spec/type.dd index 484c40f210..1cd88d909e 100644 --- a/spec/type.dd +++ b/spec/type.dd @@ -13,6 +13,7 @@ $(H2 $(LNAME2 grammar, Grammar)) $(GRAMMAR $(GNAME Type): $(GLINK TypeCtors)$(OPT) $(GLINK BasicType) $(GLINK TypeSuffixes)$(OPT) + $(D ref) $(GLINK TypeCtors)$(OPT) $(GLINK BasicType) $(GLINK CallableSuffix) $(GLINK TypeSuffixes)$(OPT) $(GNAME TypeCtors): $(GLINK TypeCtor) @@ -30,7 +31,7 @@ $(GNAME BasicType): $(GLINK QualifiedIdentifier) $(GLINK Typeof) $(GLINK Typeof) $(D .) $(GLINK QualifiedIdentifier) - $(GLINK TypeCtor) $(D $(LPAREN)) $(GLINK Type) $(D $(RPAREN)) + $(GLINK TypeCtor)$(OPT) $(D $(LPAREN)) $(GLINK Type) $(D $(RPAREN)) $(GLINK Vector) $(GLINK2 traits, TraitsExpression) $(GLINK MixinType) @@ -77,6 +78,9 @@ $(GNAME TypeSuffix): $(D [) $(GLINK2 expression, AssignExpression) $(D ]) $(D [) $(GLINK2 expression, AssignExpression) $(D ..) $(GLINK2 expression, AssignExpression) $(D ]) $(D [) $(GLINK Type) $(D ]) + $(GLINK CallableSuffix) + +$(GNAME CallableSuffix): $(D delegate) $(GLINK2 function, Parameters) $(GLINK2 function, MemberFunctionAttributes)$(OPT) $(D function) $(GLINK2 function, Parameters) $(GLINK2 function, FunctionAttributes)$(OPT) From 6c3b3788c32d4a93fe1005595640c6cc5497ba60 Mon Sep 17 00:00:00 2001 From: "Quirin F. Schroll" Date: Thu, 10 Nov 2022 10:28:03 +0100 Subject: [PATCH 02/16] Remove trailing whitespace --- spec/type.dd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/type.dd b/spec/type.dd index 1cd88d909e..d1c74a7a43 100644 --- a/spec/type.dd +++ b/spec/type.dd @@ -79,7 +79,7 @@ $(GNAME TypeSuffix): $(D [) $(GLINK2 expression, AssignExpression) $(D ..) $(GLINK2 expression, AssignExpression) $(D ]) $(D [) $(GLINK Type) $(D ]) $(GLINK CallableSuffix) - + $(GNAME CallableSuffix): $(D delegate) $(GLINK2 function, Parameters) $(GLINK2 function, MemberFunctionAttributes)$(OPT) $(D function) $(GLINK2 function, Parameters) $(GLINK2 function, FunctionAttributes)$(OPT) From 83b407850721bb071b924d6b8a80de1650631961 Mon Sep 17 00:00:00 2001 From: Quirin Schroll Date: Thu, 25 May 2023 15:13:10 +0200 Subject: [PATCH 03/16] Fix failure in dlang/dmd#15245 --- spec/traits.dd | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spec/traits.dd b/spec/traits.dd index 19e6e9557c..ae84a40fe8 100644 --- a/spec/traits.dd +++ b/spec/traits.dd @@ -1733,13 +1733,16 @@ static assert(__traits(isSame, foo, daz)); ) $(P The result is `true` if the two arguments are expressions - made up of literals or enums that evaluate to the same value.) + none of which are just symbols + that evaluate to the same value at compile-time.) $(SPEC_RUNNABLE_EXAMPLE_COMPILE --- enum e = 3; -static assert(__traits(isSame, (e), 3)); -static assert(__traits(isSame, 5, 2 + e)); +static assert(!__traits(isSame, e, 3)); // e is a symbol +static assert(!__traits(isSame, (e), 3)); // (e) is a symbol +static assert( __traits(isSame, cast(typeof(e)) e, 3)); // cast is an expression +static assert( __traits(isSame, 5, 2 + e)); // 5 and 2 + e are expressions --- ) $(P If the two arguments are both From 76e7813c18de29b8333b4f48b2360011b414ea26 Mon Sep 17 00:00:00 2001 From: Quirin Schroll Date: Fri, 28 Jun 2024 16:35:30 +0200 Subject: [PATCH 04/16] Update to match DIP draft --- spec/expression.dd | 4 ++-- spec/function.dd | 2 ++ spec/type.dd | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/spec/expression.dd b/spec/expression.dd index 4890478302..2d3a09d07b 100644 --- a/spec/expression.dd +++ b/spec/expression.dd @@ -2272,8 +2272,8 @@ $(H3 $(LNAME2 function_literals, Function Literals)) $(GRAMMAR $(GNAME FunctionLiteral): - $(D function) $(GLINK RefOrAutoRef)$(OPT) $(GLINK2 type, Type)$(OPT) $(GLINK ParameterWithAttributes)$(OPT) $(GLINK FunctionLiteralBody) - $(D delegate) $(GLINK RefOrAutoRef)$(OPT) $(GLINK2 type, Type)$(OPT) $(GLINK ParameterWithMemberAttributes)$(OPT) $(GLINK FunctionLiteralBody) + $(D function) $(GLINK2 attribute, LinkageAttribute)$(opt) $(GLINK RefOrAutoRef)$(OPT) $(GLINK2 type, Type)$(OPT) $(GLINK ParameterWithAttributes)$(OPT) $(GLINK FunctionLiteralBody) + $(D delegate) $(GLINK2 attribute, LinkageAttribute)$(opt) $(GLINK RefOrAutoRef)$(OPT) $(GLINK2 type, Type)$(OPT) $(GLINK ParameterWithMemberAttributes)$(OPT) $(GLINK FunctionLiteralBody) $(GLINK RefOrAutoRef)$(OPT) $(GLINK ParameterWithMemberAttributes) $(GLINK FunctionLiteralBody) $(GLINK2 statement, BlockStatement) $(IDENTIFIER) $(D =>) $(GLINK AssignExpression) diff --git a/spec/function.dd b/spec/function.dd index 11c2f44b0f..8b240a2a4e 100644 --- a/spec/function.dd +++ b/spec/function.dd @@ -48,6 +48,8 @@ $(GNAME Parameter): $(GNAME ParameterDeclaration): $(GLINK ParameterAttributes)$(OPT) $(GLINK2 type, BasicType) $(GLINK2 declaration, Declarator) + $(GLINK ParameterAttributes)$(OPT) $(GLINK2 attribute, LinkageAttribute) $(GLINK2 type, TypeCtors)$(opt) $(GLINK2 type, BasicType) $(GLINK2 declaration, Declarator) + $(GLINK ParameterAttributes)$(OPT) $(GLINK2 attribute, LinkageAttribute) `ref` $(GLINK2 type, TypeCtors)$(opt) $(GLINK2 type, BasicType) $(GLINK2 declaration, Declarator) $(GLINK ParameterAttributes)$(OPT) $(GLINK2 type, Type) $(GNAME ParameterAttributes): diff --git a/spec/type.dd b/spec/type.dd index cc951faa12..cf2a15a836 100644 --- a/spec/type.dd +++ b/spec/type.dd @@ -13,7 +13,9 @@ $(H2 $(LNAME2 grammar, Grammar)) $(GRAMMAR $(GNAME Type): $(GLINK TypeCtors)$(OPT) $(GLINK BasicType) $(GLINK TypeSuffixes)$(OPT) - $(D ref) $(GLINK TypeCtors)$(OPT) $(GLINK BasicType) $(GLINK CallableSuffix) $(GLINK TypeSuffixes)$(OPT) + $(GLINK TypeCtors)$(OPT) $(D ref) $(GLINK TypeCtors)$(OPT) $(GLINK BasicType) $(GLINK TypeSuffixes) + $(GLINK TypeCtors)$(OPT) $(GLINK2 attribute, LinkageAttribute) $(GLINK TypeCtors)$(OPT) $(GLINK BasicType) $(GLINK TypeSuffixes) + $(GLINK TypeCtors)$(OPT) $(GLINK2 attribute, LinkageAttribute) $(D ref) $(GLINK TypeCtors)$(OPT) $(GLINK BasicType) $(GLINK TypeSuffixes) $(GNAME TypeCtors): $(GLINK TypeCtor) From ab120f92922dc51f21c121584f82027723b615ab Mon Sep 17 00:00:00 2001 From: Quirin Schroll Date: Tue, 2 Jul 2024 19:07:26 +0200 Subject: [PATCH 05/16] Fix failing tests --- spec/traits.dd | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/traits.dd b/spec/traits.dd index 0eaece0614..05c3f39059 100644 --- a/spec/traits.dd +++ b/spec/traits.dd @@ -1802,7 +1802,6 @@ $(SPEC_RUNNABLE_EXAMPLE_COMPILE --- enum e = 3; static assert(!__traits(isSame, e, 3)); // e is a symbol -static assert(!__traits(isSame, (e), 3)); // (e) is a symbol static assert( __traits(isSame, cast(typeof(e)) e, 3)); // cast is an expression static assert( __traits(isSame, 5, 2 + e)); // 5 and 2 + e are expressions --- From ee43b047deac699eac8eba7e1020f8de1d547b32 Mon Sep 17 00:00:00 2001 From: Quirin Schroll Date: Wed, 3 Jul 2024 19:36:47 +0200 Subject: [PATCH 06/16] Mention `CallableSuffix` requirement --- spec/type.dd | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/type.dd b/spec/type.dd index cf2a15a836..98ed0f5834 100644 --- a/spec/type.dd +++ b/spec/type.dd @@ -99,6 +99,11 @@ $(GNAME QualifiedIdentifier): * $(RELATIVE_LINK2 derived-data-types, Derived Data Types) build on leaf types. * $(RELATIVE_LINK2 user-defined-types, User-Defined Types) are aggregates of basic and derived types. +$(P For a $(GLINK Type) to be well-formed, +if it uses a $(GLINK2 attribute, LinkageAttribute) and/or `ref`, +the sequence of $(GLINK TypeSuffixes) must include exactly one $(GLINK CallableSuffix).) + + $(H2 $(LEGACY_LNAME2 Basic Data Types, basic-data-types, Basic Data Types)) $(TABLE_3COLS Basic Data Types, From f55cbce59f629158f302cac80cdebf7a1ca90c35 Mon Sep 17 00:00:00 2001 From: Quirin Schroll Date: Wed, 3 Jul 2024 19:38:58 +0200 Subject: [PATCH 07/16] Explain linkage and `ref` for function pointer types --- spec/type.dd | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/spec/type.dd b/spec/type.dd index 98ed0f5834..1e1eed9454 100644 --- a/spec/type.dd +++ b/spec/type.dd @@ -617,13 +617,19 @@ A function type e.g. `int(int)` $(DDSUBLINK spec/declaration, alias-function, ca A function type is only used for type tests or as the target type of a pointer.) $(P Instantiating a function type is illegal. Instead, a pointer to function -or delegate can be used. Those have these type forms respectively:) +or delegate can be used. Somewhat simplified, those have these type forms respectively:) $(GRAMMAR_INFORMATIVE -$(GLINK Type) `function` $(GLINK2 function, Parameters) $(GLINK2 function, FunctionAttributes)$(OPT) -$(GLINK Type) `delegate` $(GLINK2 function, Parameters) $(GLINK2 function, MemberFunctionAttributes)$(OPT) +$(GLINK2 attribute, LinkageAttribute)$(OPT) $(GLINK Type) `function` $(GLINK2 function, Parameters) $(GLINK2 function, FunctionAttributes)$(OPT) +$(GLINK2 attribute, LinkageAttribute)$(OPT) $(GLINK Type) `delegate` $(GLINK2 function, Parameters) $(GLINK2 function, MemberFunctionAttributes)$(OPT) + +$(GLINK2 attribute, LinkageAttribute)$(OPT) $(D ref) $(GLINK BasicType) `function` $(GLINK2 function, Parameters) $(GLINK2 function, FunctionAttributes)$(OPT) +$(GLINK2 attribute, LinkageAttribute)$(OPT) $(D ref) $(GLINK BasicType) `delegate` $(GLINK2 function, Parameters) $(GLINK2 function, MemberFunctionAttributes)$(OPT) ) +$(P When linkage attributes and/or `ref` are present, a function pointer or delegate type is not a $(GLINK BasicType), +and some contexts require surrounding them by parentheses. + $(SPEC_RUNNABLE_EXAMPLE_COMPILE --- void f(int); From 63ddf581dfe39dd8bc06b95895dbcba34ce78aa9 Mon Sep 17 00:00:00 2001 From: Quirin Schroll Date: Wed, 3 Jul 2024 19:39:25 +0200 Subject: [PATCH 08/16] Prepare example --- spec/type.dd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/type.dd b/spec/type.dd index 1e1eed9454..14d6c2b5d3 100644 --- a/spec/type.dd +++ b/spec/type.dd @@ -636,6 +636,10 @@ void f(int); alias Fun = void(int); static assert(is(typeof(f) == Fun)); static assert(is(Fun* == void function(int))); + +// ref int g(ref int x) => x; +// (ref int function(ref int)) fp = &g; // variable declaration requires `()` +// static assert(is(typeof(fp) == ref int function(ref int))); // `is` requires no extra `()` --- ) From 3d2a525bc56502a0919e2ed6f686189d7ba10ddf Mon Sep 17 00:00:00 2001 From: Quirin Schroll Date: Mon, 15 Jul 2024 13:53:12 +0200 Subject: [PATCH 09/16] Update spec to reflect proposed grammar changes --- spec/statement.dd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/statement.dd b/spec/statement.dd index 832ffc88ee..3e1cc6e62e 100644 --- a/spec/statement.dd +++ b/spec/statement.dd @@ -241,6 +241,8 @@ $(GNAME IfCondition): $(EXPRESSION) $(GLINK IfConditionStorageClasses) $(GLINK_LEX Identifier) $(D =) $(EXPRESSION) $(GLINK IfConditionStorageClasses)$(OPT) $(GLINK2 type, BasicType) $(GLINK2 declaration, Declarator) $(D =) $(EXPRESSION) + $(GLINK IfConditionStorageClasses)$(OPT) $(GLINK2 attribute, LinkageAttribute) $(GLINK2 type, TypeCtors)$(OPT) $(GLINK2 type, BasicType) $(GLINK2 declaration, Declarator) $(D =) $(EXPRESSION) + $(GLINK IfConditionStorageClasses)$(OPT) $(GLINK2 attribute, LinkageAttribute) $(D ref) $(GLINK2 type, TypeCtors)$(OPT) $(GLINK2 type, BasicType) $(GLINK2 declaration, Declarator) $(D =) $(EXPRESSION) $(GNAME IfConditionStorageClasses): $(GLINK IfConditionStorageClass) From 5d883d554d93f1ef73c0c1d3df424c85e95c793a Mon Sep 17 00:00:00 2001 From: Quirin Schroll Date: Sun, 22 Sep 2024 02:08:10 +0200 Subject: [PATCH 10/16] Update spec to reflect proposed grammar changes --- spec/expression.dd | 7 +++++-- spec/function.dd | 2 +- spec/statement.dd | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/spec/expression.dd b/spec/expression.dd index 3055977bcf..f918d48d8d 100644 --- a/spec/expression.dd +++ b/spec/expression.dd @@ -2242,8 +2242,8 @@ $(H3 $(LNAME2 function_literals, Function Literals)) $(GRAMMAR $(GNAME FunctionLiteral): - $(D function) $(GLINK2 attribute, LinkageAttribute)$(opt) $(GLINK RefOrAutoRef)$(OPT) $(GLINK2 type, Type)$(OPT) $(GLINK ParameterWithAttributes)$(OPT) $(GLINK FunctionLiteralBody) - $(D delegate) $(GLINK2 attribute, LinkageAttribute)$(opt) $(GLINK RefOrAutoRef)$(OPT) $(GLINK2 type, Type)$(OPT) $(GLINK ParameterWithMemberAttributes)$(OPT) $(GLINK FunctionLiteralBody) + $(D function) $(GLINK2 attribute, LinkageAttribute)$(opt) $(GLINK RefOrAutoRef)$(OPT) $(GLINK SuffixedBasicType)$(OPT) $(GLINK ParameterWithAttributes)$(OPT) $(GLINK FunctionLiteralBody) + $(D delegate) $(GLINK2 attribute, LinkageAttribute)$(opt) $(GLINK RefOrAutoRef)$(OPT) $(GLINK SuffixedBasicType)$(OPT) $(GLINK ParameterWithMemberAttributes)$(OPT) $(GLINK FunctionLiteralBody) $(GLINK RefOrAutoRef)$(OPT) $(GLINK ParameterWithMemberAttributes) $(GLINK FunctionLiteralBody) $(GLINK2 statement, BlockStatement) $(IDENTIFIER) $(D =>) $(GLINK AssignExpression) @@ -2261,6 +2261,9 @@ $(GNAME FunctionLiteralBody): $(GNAME RefOrAutoRef): $(D ref) $(D auto ref) + +$(GNAME SuffixedBasicType): + $(GLINK2 type, BasicType) $(GLINK2 type, TypeSuffixes)$(OPT) ) $(P $(I FunctionLiteral)s enable embedding anonymous functions diff --git a/spec/function.dd b/spec/function.dd index 006725cf6a..33ee8c73fa 100644 --- a/spec/function.dd +++ b/spec/function.dd @@ -49,7 +49,7 @@ $(GNAME Parameter): $(GNAME ParameterDeclaration): $(GLINK ParameterAttributes)$(OPT) $(GLINK2 type, BasicType) $(GLINK2 declaration, Declarator) $(GLINK ParameterAttributes)$(OPT) $(GLINK2 attribute, LinkageAttribute) $(GLINK2 type, TypeCtors)$(opt) $(GLINK2 type, BasicType) $(GLINK2 declaration, Declarator) - $(GLINK ParameterAttributes)$(OPT) $(GLINK2 attribute, LinkageAttribute) `ref` $(GLINK2 type, TypeCtors)$(opt) $(GLINK2 type, BasicType) $(GLINK2 declaration, Declarator) + $(GLINK ParameterAttributes)$(OPT) $(GLINK2 attribute, LinkageAttribute) $(D ref) $(GLINK2 type, TypeCtors)$(opt) $(GLINK2 type, BasicType) $(GLINK2 declaration, Declarator) $(GLINK ParameterAttributes)$(OPT) $(GLINK2 type, Type) $(GNAME ParameterAttributes): diff --git a/spec/statement.dd b/spec/statement.dd index 3e1cc6e62e..f6f88aeca4 100644 --- a/spec/statement.dd +++ b/spec/statement.dd @@ -503,6 +503,8 @@ $(GNAME ForeachTypeList): $(GNAME ForeachType): $(GLINK ForeachTypeAttributes)$(OPT) $(GLINK2 type, BasicType) $(GLINK2 declaration, Declarator) + $(GLINK ForeachTypeAttributes)$(OPT) $(GLINK2 attribute, LinkageAttribute) $(GLINK2 type, BasicType) $(GLINK2 declaration, Declarator) + $(GLINK ForeachTypeAttributes)$(OPT) $(GLINK2 attribute, LinkageAttribute) $(D ref) $(GLINK2 type, BasicType) $(GLINK2 declaration, Declarator) $(GLINK ForeachTypeAttributes)$(OPT) $(GLINK_LEX Identifier) $(GLINK ForeachTypeAttributes)$(OPT) $(D alias) $(GLINK_LEX Identifier) From 18681470c5f711ba81b5be41a94c86cd061d486c Mon Sep 17 00:00:00 2001 From: "Quirin F. Schroll" Date: Thu, 6 Feb 2025 14:56:57 +0100 Subject: [PATCH 11/16] Remove unused grammar entity --- spec/expression.dd | 4 ---- 1 file changed, 4 deletions(-) diff --git a/spec/expression.dd b/spec/expression.dd index 0771de1eba..ff6e1da5cf 100644 --- a/spec/expression.dd +++ b/spec/expression.dd @@ -2416,10 +2416,6 @@ $(GNAME RefOrAutoRef): $(D ref) $(D auto ref) -$(GNAME SuffixedBasicType): - $(GLINK2 type, BasicType) $(GLINK2 type, TypeSuffixes)$(OPT) -) - $(P $(I FunctionLiteral)s enable embedding anonymous functions and anonymous delegates directly into expressions. Short function literals are known as $(LNAME2 lambdas, $(I lambdas)). From 5c273cd1e87de3043d3e9eaa2f8067ce2f42a150 Mon Sep 17 00:00:00 2001 From: "Quirin F. Schroll" Date: Thu, 6 Feb 2025 15:36:27 +0100 Subject: [PATCH 12/16] =?UTF-8?q?opt=20=E2=86=92=20OPT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/expression.dd | 4 ++-- spec/function.dd | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/expression.dd b/spec/expression.dd index ff6e1da5cf..7b834ccfbc 100644 --- a/spec/expression.dd +++ b/spec/expression.dd @@ -2393,8 +2393,8 @@ $(H3 $(LNAME2 function_literals, Function Literals)) $(GRAMMAR $(GNAME FunctionLiteral): - $(D function) $(GLINK2 attribute, LinkageAttribute)$(opt) $(GLINK RefOrAutoRef)$(OPT) $(GLINK BasicTypeWithSuffixes)$(OPT) $(GLINK ParameterWithAttributes)$(OPT) $(GLINK FunctionLiteralBody) - $(D delegate) $(GLINK2 attribute, LinkageAttribute)$(opt) $(GLINK RefOrAutoRef)$(OPT) $(GLINK BasicTypeWithSuffixes)$(OPT) $(GLINK ParameterWithMemberAttributes)$(OPT) $(GLINK FunctionLiteralBody) + $(D function) $(GLINK2 attribute, LinkageAttribute)$(OPT) $(GLINK RefOrAutoRef)$(OPT) $(GLINK BasicTypeWithSuffixes)$(OPT) $(GLINK ParameterWithAttributes)$(OPT) $(GLINK FunctionLiteralBody) + $(D delegate) $(GLINK2 attribute, LinkageAttribute)$(OPT) $(GLINK RefOrAutoRef)$(OPT) $(GLINK BasicTypeWithSuffixes)$(OPT) $(GLINK ParameterWithMemberAttributes)$(OPT) $(GLINK FunctionLiteralBody) $(GLINK RefOrAutoRef)$(OPT) $(GLINK ParameterWithMemberAttributes) $(GLINK FunctionLiteralBody) $(GLINK2 statement, BlockStatement) $(IDENTIFIER) $(D =>) $(GLINK AssignExpression) diff --git a/spec/function.dd b/spec/function.dd index c3948bd3eb..094836c580 100644 --- a/spec/function.dd +++ b/spec/function.dd @@ -50,8 +50,8 @@ $(GNAME Parameter): $(GNAME ParameterDeclaration): $(GLINK ParameterAttributes)$(OPT) $(GLINK2 type, BasicType) $(GLINK2 declaration, Declarator) - $(GLINK ParameterAttributes)$(OPT) $(GLINK2 attribute, LinkageAttribute) $(GLINK2 type, TypeCtors)$(opt) $(GLINK2 type, BasicType) $(GLINK2 declaration, Declarator) - $(GLINK ParameterAttributes)$(OPT) $(GLINK2 attribute, LinkageAttribute) $(D ref) $(GLINK2 type, TypeCtors)$(opt) $(GLINK2 type, BasicType) $(GLINK2 declaration, Declarator) + $(GLINK ParameterAttributes)$(OPT) $(GLINK2 attribute, LinkageAttribute) $(GLINK2 type, TypeCtors)$(OPT) $(GLINK2 type, BasicType) $(GLINK2 declaration, Declarator) + $(GLINK ParameterAttributes)$(OPT) $(GLINK2 attribute, LinkageAttribute) $(D ref) $(GLINK2 type, TypeCtors)$(OPT) $(GLINK2 type, BasicType) $(GLINK2 declaration, Declarator) $(GLINK ParameterAttributes)$(OPT) $(GLINK2 type, Type) $(GNAME ParameterAttributes): From d32e2608c41af85ce5da660e24dd2b411dcf5c00 Mon Sep 17 00:00:00 2001 From: "Quirin F. Schroll" Date: Thu, 6 Feb 2025 19:25:22 +0100 Subject: [PATCH 13/16] Add closing parenthesis --- spec/expression.dd | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/expression.dd b/spec/expression.dd index 7b834ccfbc..4ae2b488ce 100644 --- a/spec/expression.dd +++ b/spec/expression.dd @@ -2415,6 +2415,7 @@ $(GNAME FunctionLiteralBody): $(GNAME RefOrAutoRef): $(D ref) $(D auto ref) +) $(P $(I FunctionLiteral)s enable embedding anonymous functions and anonymous delegates directly into expressions. From 856eed43a902bf163fc5eda78e8296f8f9870bb3 Mon Sep 17 00:00:00 2001 From: "Quirin F. Schroll" Date: Thu, 6 Feb 2025 21:40:30 +0100 Subject: [PATCH 14/16] Add clause for linkage attributes for parameters, if, and foreach --- spec/function.dd | 2 ++ spec/statement.dd | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/spec/function.dd b/spec/function.dd index 094836c580..ef6b6769eb 100644 --- a/spec/function.dd +++ b/spec/function.dd @@ -82,6 +82,8 @@ $(GNAME VariadicArgumentsAttribute): $(D scope) $(D shared) ) +$(P When $(I LinkageAttribute) is present, +the $(I Declarator) must include exactly one $(I CallableSuffix).) $(NOTE In D2, declaring a parameter `final` is a semantic error, but not a parse error.) diff --git a/spec/statement.dd b/spec/statement.dd index c772ac568c..c80be3508e 100644 --- a/spec/statement.dd +++ b/spec/statement.dd @@ -261,6 +261,9 @@ $(GNAME ElseStatement): $(PSSCOPE) ) + $(P When $(I LinkageAttribute) is present, + the $(I Declarator) must include exactly one $(I CallableSuffix).) + $(P If there is a declared *Identifier* variable, $(RELATIVE_LINK2 condition-variables, it is evaluated). Otherwise, *Expression* is evaluated. The result is converted to a @@ -520,6 +523,11 @@ $(GNAME ForeachAggregate): $(EXPRESSION) ) +$(P + When $(I LinkageAttribute) is present, + the $(I Declarator) must include exactly one $(I CallableSuffix). +) + $(P $(I ForeachAggregate) is evaluated. It must evaluate to an expression which is a static array, dynamic array, associative array, From df1cca87c563bfa86ced47783782bacd782fd588 Mon Sep 17 00:00:00 2001 From: "Quirin F. Schroll" Date: Wed, 12 Feb 2025 16:18:27 +0100 Subject: [PATCH 15/16] Specify virtual parens through `ref` and `function` --- spec/type.dd | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/type.dd b/spec/type.dd index 4324a9dee8..04c7d9e7d6 100644 --- a/spec/type.dd +++ b/spec/type.dd @@ -101,8 +101,10 @@ $(GNAME QualifiedIdentifier): $(P For a $(GLINK Type) to be well-formed, if it uses a $(GLINK2 attribute, LinkageAttribute) and/or `ref`, -the sequence of $(GLINK TypeSuffixes) must include exactly one $(GLINK CallableSuffix).) - +the sequence of $(GLINK TypeSuffixes) must include exactly one $(GLINK CallableSuffix). +Initial $(GLINK TypeCtors) (if present) refer to the whole type produced, +whereas $(GLINK TypeCtors) after $(I LinkageAttribute) and/or `ref` (if present) refer to the return type only: +`const ref immutable int[] function()[]` is the same as `const(ref immutable(int[]) function()[])`.) $(H2 $(LEGACY_LNAME2 Basic Data Types, basic-data-types, Basic Data Types)) From 39d1f60ac55e38afcf163e94ddf9506d931f9731 Mon Sep 17 00:00:00 2001 From: "Quirin F. Schroll" Date: Thu, 13 Feb 2025 13:38:04 +0100 Subject: [PATCH 16/16] Only link `Type`, remove example --- spec/type.dd | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/spec/type.dd b/spec/type.dd index 04c7d9e7d6..c48b10fffa 100644 --- a/spec/type.dd +++ b/spec/type.dd @@ -100,11 +100,10 @@ $(GNAME QualifiedIdentifier): * $(RELATIVE_LINK2 user-defined-types, User-Defined Types) are aggregates of basic and derived types. $(P For a $(GLINK Type) to be well-formed, -if it uses a $(GLINK2 attribute, LinkageAttribute) and/or `ref`, -the sequence of $(GLINK TypeSuffixes) must include exactly one $(GLINK CallableSuffix). -Initial $(GLINK TypeCtors) (if present) refer to the whole type produced, -whereas $(GLINK TypeCtors) after $(I LinkageAttribute) and/or `ref` (if present) refer to the return type only: -`const ref immutable int[] function()[]` is the same as `const(ref immutable(int[]) function()[])`.) +if it uses a *LinkageAttribute* and/or `ref`, +the sequence of *TypeSuffixes* must include exactly one *CallableSuffix*; +then, initial *TypeCtors* refer to the whole type, +whereas *TypeCtors* after *LinkageAttribute* and/or `ref` affect the return type.) $(H2 $(LEGACY_LNAME2 Basic Data Types, basic-data-types, Basic Data Types))