From 08b709967ad3aac6034a30b5e041e1fa59c4ab34 Mon Sep 17 00:00:00 2001 From: Rex Jaeschke Date: Thu, 12 Feb 2026 16:13:49 -0500 Subject: [PATCH 1/2] support Auto-default structs --- standard/expressions.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/standard/expressions.md b/standard/expressions.md index 82ce81a03..b181a922c 100644 --- a/standard/expressions.md +++ b/standard/expressions.md @@ -2563,7 +2563,9 @@ A *this_access* is permitted only in the *block* of an instance constructor, an - When `this` is used in a *primary_expression* within an instance constructor of a class, it is classified as a value. The type of the value is the instance type ([§15.3.2](classes.md#1532-the-instance-type)) of the class within which the usage occurs, and the value is a reference to the object being constructed. - When `this` is used in a *primary_expression* within an instance method or instance accessor of a class, it is classified as a value. The type of the value is the instance type ([§15.3.2](classes.md#1532-the-instance-type)) of the class within which the usage occurs, and the value is a reference to the object for which the method or accessor was invoked. - When `this` is used in a *primary_expression* within an instance constructor of a struct, it is classified as a variable. The type of the variable is the instance type ([§15.3.2](classes.md#1532-the-instance-type)) of the struct within which the usage occurs, and the variable represents the struct being constructed. - - If the constructor declaration has no constructor initializer, the `this` variable behaves exactly the same as an output parameter of the struct type. In particular, this means that the variable shall be definitely assigned in every execution path of the instance constructor. + - If the constructor declaration has no constructor initializer, the `this` variable behaves similarly to an output parameter of the struct type, except that it is not an error when the definite assignment requirements ([§9.4.1](variables.md#941-general)) are not met. Instead, the following occurs: + 1. When the `this` variable itself does not meet the requirements, then all unassigned instance variables within `this` at all points where requirements are violated are implicitly initialized to the default value ([§9.3]( variables.md#93-default-values)) in an *initialization* phase before any other code in the constructor runs. + 1. When an instance variable *v* within `this` does not meet the requirements, or any instance variable at any level of nesting within *v* does not meet the requirements, then *v* is implicitly initialized to the default value in an *initialization* phase before any other code in the constructor runs. - Otherwise, the `this` variable behaves exactly the same as a `ref` parameter of the struct type. In particular, this means that the variable is considered initially assigned. - When `this` is used in a *primary_expression* within an instance method or instance accessor of a struct, it is classified as a variable. The type of the variable is the instance type ([§15.3.2](classes.md#1532-the-instance-type)) of the struct within which the usage occurs. - If the method or accessor is not an iterator ([§15.15](classes.md#1515-synchronous-and-asynchronous-iterators)) or async function ([§15.14](classes.md#1514-async-functions)), the `this` variable represents the struct for which the method or accessor was invoked. From 3ba370922f039bfa79edb9b1c2f3b7ddf9873646 Mon Sep 17 00:00:00 2001 From: Rex Jaeschke Date: Fri, 13 Feb 2026 12:27:44 -0500 Subject: [PATCH 2/2] fix list md --- standard/expressions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/standard/expressions.md b/standard/expressions.md index b181a922c..88472c408 100644 --- a/standard/expressions.md +++ b/standard/expressions.md @@ -2564,8 +2564,8 @@ A *this_access* is permitted only in the *block* of an instance constructor, an - When `this` is used in a *primary_expression* within an instance method or instance accessor of a class, it is classified as a value. The type of the value is the instance type ([§15.3.2](classes.md#1532-the-instance-type)) of the class within which the usage occurs, and the value is a reference to the object for which the method or accessor was invoked. - When `this` is used in a *primary_expression* within an instance constructor of a struct, it is classified as a variable. The type of the variable is the instance type ([§15.3.2](classes.md#1532-the-instance-type)) of the struct within which the usage occurs, and the variable represents the struct being constructed. - If the constructor declaration has no constructor initializer, the `this` variable behaves similarly to an output parameter of the struct type, except that it is not an error when the definite assignment requirements ([§9.4.1](variables.md#941-general)) are not met. Instead, the following occurs: - 1. When the `this` variable itself does not meet the requirements, then all unassigned instance variables within `this` at all points where requirements are violated are implicitly initialized to the default value ([§9.3]( variables.md#93-default-values)) in an *initialization* phase before any other code in the constructor runs. - 1. When an instance variable *v* within `this` does not meet the requirements, or any instance variable at any level of nesting within *v* does not meet the requirements, then *v* is implicitly initialized to the default value in an *initialization* phase before any other code in the constructor runs. + - When the `this` variable itself does not meet the requirements, then all unassigned instance variables within `this` at all points where requirements are violated are implicitly initialized to the default value ([§9.3]( variables.md#93-default-values)) in an *initialization* phase before any other code in the constructor runs. + - When an instance variable *v* within `this` does not meet the requirements, or any instance variable at any level of nesting within *v* does not meet the requirements, then *v* is implicitly initialized to the default value in an *initialization* phase before any other code in the constructor runs. - Otherwise, the `this` variable behaves exactly the same as a `ref` parameter of the struct type. In particular, this means that the variable is considered initially assigned. - When `this` is used in a *primary_expression* within an instance method or instance accessor of a struct, it is classified as a variable. The type of the variable is the instance type ([§15.3.2](classes.md#1532-the-instance-type)) of the struct within which the usage occurs. - If the method or accessor is not an iterator ([§15.15](classes.md#1515-synchronous-and-asynchronous-iterators)) or async function ([§15.14](classes.md#1514-async-functions)), the `this` variable represents the struct for which the method or accessor was invoked.