Skip to content

Commit 56b02e4

Browse files
committed
Specify defensive copy for other readonly variables
Addresses dotnet#894 (comment)
1 parent dbbec79 commit 56b02e4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

standard/expressions.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,11 @@ The run-time processing of a function member invocation consists of the followin
12111211
- `M` is invoked.
12121212
- Otherwise, if the type of `E` is a value-type `V`, and `M` is declared or overridden in `V`:
12131213
- `E` is evaluated. If this evaluation causes an exception, then no further steps are executed. For an instance constructor, this evaluation consists of allocating storage (typically from an execution stack) for the new object. In this case `E` is classified as a variable.
1214-
- If `E` is not classified as a variable, or if `E` is an input parameter15.6.2.3) and `V` is not a readonly struct type16.2.2), then a temporary local variable of `E`’s type is created and the value of `E` is assigned to that variable. `E` is then reclassified as a reference to that temporary local variable. The temporary variable is accessible as `this` within `M`, but not in any other way. Thus, only when `E` is a true variable is it possible for the caller to observe the changes that `M` makes to `this`.
1214+
- If `E` is not classified as a variable, or if `V` is not a readonly struct type16.2.2), and `E` is one of:
1215+
- an input parameter15.6.2.3), or
1216+
- a `readonly` field15.5.3), or
1217+
- a `readonly` reference variable or return9.7),
1218+
then a temporary local variable of `E`’s type is created and the value of `E` is assigned to that variable. `E` is then reclassified as a reference to that temporary local variable. The temporary variable is accessible as `this` within `M`, but not in any other way. Thus, only when `E` is a true variable is it possible for the caller to observe the changes that `M` makes to `this`.
12151219
- The argument list is evaluated as described in [§12.6.2](expressions.md#1262-argument-lists).
12161220
- `M` is invoked. The variable referenced by `E` becomes the variable referenced by `this`.
12171221
- Otherwise:

0 commit comments

Comments
 (0)