Skip to content

Commit 88f9f1a

Browse files
BillWagnerjskeet
authored andcommitted
Specify temporary for this as an input parameter
First commit: Fix the issue raised in the description of #894: If a method takes an `in` parameter of a struct type that is not a `readonly struct`, then the compiler must create a temporary to invoke a non-readonly member of that type.
1 parent 23975a0 commit 88f9f1a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

standard/expressions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ 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, 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 `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`.
12151215
- The argument list is evaluated as described in [§12.6.2](expressions.md#1262-argument-lists).
12161216
- `M` is invoked. The variable referenced by `E` becomes the variable referenced by `this`.
12171217
- Otherwise:

0 commit comments

Comments
 (0)