Skip to content

Commit e050360

Browse files
committed
Review updates
- Grammar allows `record` and `record class` - `with` expressions allowed in non-record struct types - a couple small merge issues where text was lost
1 parent 5d104fb commit e050360

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

standard/classes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class_declaration
2121
2222
class_tag
2323
: 'class'
24-
| 'record'
24+
| 'record' 'class'?
2525
;
2626
```
2727

@@ -31,7 +31,7 @@ A class declaration shall not supply *type_parameter_constraints_clause*s unless
3131

3232
A class declaration that supplies a *type_parameter_list* is a generic class declaration. Additionally, any class nested inside a generic class declaration or a generic struct declaration is itself a generic class declaration, since type arguments for the containing type shall be supplied to create a constructed type ([§8.4](types.md#84-constructed-types)).
3333

34-
If *class_tag* contains `record`, that class is a ***record class***; otherwise, it is a ***non-record class***.
34+
If *class_tag* contains `record`, that class is a ***record class***; otherwise, it is a ***non-record class***. `record` and `record class` are equivalent.
3535

3636
For a record class, *class_modifier* shall not be `static`.
3737

standard/expressions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3934,6 +3934,7 @@ All non-positional properties being changed shall have both set and init accesso
39343934
This expression is evaluated as follows:
39353935

39363936
- For a record class type, the receiver's clone method ([§15.16.3](classes.md#15163-copy-and-clone-members)) is invoked, and its result is converted to the receiver’s type.
3937+
- For a record struct or non-record struct type, the receiver is copied.
39373938
- Each `member_initializer` is processed the same way as an assignment to
39383939
a field or property access of the result of the conversion. Assignments are processed in lexical order. If *member_initializer_list* is omitted, no members are changed.
39393940

standard/structs.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ A *struct_declaration* is for either a ***non-record struct*** or a ***record st
4242

4343
A *non_record_struct_declaration* consists of an optional set of *attributes* ([§23](attributes.md#23-attributes)), followed by an optional set of *struct_modifier*s ([§16.2.2](structs.md#1622-struct-modifiers)), followed by an optional `ref` modifier ([§16.2.3](structs.md#1623-ref-modifier)), followed by an optional partial modifier ([§15.2.7](classes.md#1527-partial-type-declarations)), followed by the keyword `struct` and an *identifier* that names the struct, followed by an optional *type_parameter_list* specification ([§15.2.3](classes.md#1523-type-parameters)), followed by an optional *struct_interfaces* specification ([§16.2.5](structs.md#1625-struct-interfaces)), followed by an optional *type_parameter_constraints-clauses* specification ([§15.2.5](classes.md#1525-type-parameter-constraints)), followed by a *struct_body* ([§16.2.6](structs.md#1626-struct-body)), optionally followed by a semicolon.
4444

45-
A *record_struct_declaration* consists of an optional set of *attributes* ([§23](attributes.md#23-attributes)), followed by an optional set of *struct_modifier*s ([§16.2.2](structs.md#1622-struct-modifiers)), followed by an optional partial modifier ([§15.2.7](classes.md#1527-partial-type-declarations)), followed by the keyword `record`, followed by the keyword `struct` and an *identifier* that names the struct, followed by an optional *type_parameter_list* specification ([§15.2.3](classes.md#1523-type-parameters)), followed by an optional *delimited_parameter_list* specification ([§15.2.1](classes.md#1521-general), followed by an optional *struct_interfaces* specification ([§16.2.5](structs.md#1625-struct-interfaces)), followed by an optional *type_parameter_constraints-clauses* specification ([§15.2.5](classes.md#1525-type-parameter-constraints)), followed by a *record_struct_body*.
45+
A *record_struct_declaration* consists of an optional set of *attributes* ([§23](attributes.md#23-attributes)), followed by an optional set of *struct_modifier*s ([§16.2.2](structs.md#1622-struct-modifiers)), followed by an optional partial modifier ([§15.2.7](classes.md#1527-partial-type-declarations)), followed by the keyword `record`, followed by the keyword `struct` and an *identifier* that names the struct, followed by an optional *type_parameter_list* specification ([§15.2.3](classes.md#1523-type-parameters)), followed by an optional *delimited_parameter_list* specification ([§15.2.1](classes.md#1521-general)), followed by an optional *struct_interfaces* specification ([§16.2.5](structs.md#1625-struct-interfaces)), followed by an optional *type_parameter_constraints-clauses* specification ([§15.2.5](classes.md#1525-type-parameter-constraints)), followed by a *record_struct_body*.
4646

4747
A *struct_declaration* shall not supply *type_parameter_constraints_clause*s unless it also supplies a *type_parameter_list*.
4848

@@ -141,6 +141,8 @@ struct_body
141141

142142
## 16.3 Struct members
143143

144+
### 16.3.1 General
145+
144146
The members of a struct consist of the members introduced by its *struct_member_declaration*s and the members inherited from the type `System.ValueType`. For a record struct, the member set also includes the synthesized members generated by the compiler (§synth-members).
145147

146148
```ANTLR
@@ -167,8 +169,6 @@ Except for the differences noted in [§16.4](structs.md#164-class-and-struct-dif
167169

168170
It is an error for a member of a record struct to be named `Clone`.
169171

170-
It is an error for a member of a record struct to be named `Clone`.
171-
172172
It is an error for an instance field of a record struct to have an unsafe type.
173173

174174
### 16.3.2 Readonly members
@@ -205,6 +205,10 @@ An instance member definition or accessor of an instance property, indexer, or e
205205
> throw new InvalidOperationException("Messages collection is not initialized.");
206206
> }
207207
> messages.Add(message);
208+
> }
209+
> }
210+
> ```
211+
>
208212
> The `readonly` method `AddMessage` can change the state of a message list. The `InitializeMessages` member can clear and re-initialize the list of messages. In the case of `AddMessage`, the `readonly` modifier is valid. In the case of `InitializeMessages`, adding the `readonly` modifier is invalid. *end example*
209213
210214
## §synth-members Synthesized record struct members

0 commit comments

Comments
 (0)