Skip to content

Commit 66836f3

Browse files
committed
Apply non-semantic changes from #1538
The hope is that this can reduce the diff in #1538, making it easier to review.
1 parent 115131a commit 66836f3

1 file changed

Lines changed: 41 additions & 39 deletions

File tree

standard/expressions.md

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,12 +1639,12 @@ A *deconstruction_expression* `var (e1, ..., en)` is shorthand for the *tuple_ex
16391639
16401640
A tuple expression has a type if and only if each of its element expressions `Ei` has a type `Ti`. The type shall be a tuple type of the same arity as the tuple expression, where each element is given by the following:
16411641
1642-
- If the tuple element in the corresponding position has a name `Ni`, then the tuple type element shall be `Ti Ni`.
1643-
- Otherwise, if `Ei` is of the form `Ni` or `E.Ni` or `E?.Ni` then the tuple type element shall be `Ti Ni`, *unless* any of the following holds:
1644-
- Another element of the tuple expression has the name `Ni`, or
1645-
- Another tuple element without a name has a tuple element expression of the form `Ni` or `E.Ni` or `E?.Ni`, or
1646-
- `Ni` is of the form `ItemX`, where `X` is a sequence of non-`0`-initiated decimal digits that could represent the position of a tuple element, and `X` does not represent the position of the element.
1647-
- Otherwise, the tuple type element shall be `Ti`.
1642+
- If the tuple element in the corresponding position has a name `N`, then the tuple type element shall be `TN`.
1643+
- Otherwise, if `E` is of the form `N` or `E.N` or `E?.N` then the tuple type element shall be `TN`, *unless* any of the following holds:
1644+
- Another element of the tuple expression has the name `N`, or
1645+
- Another tuple element without a name has a tuple element expression of the form `N` or `E.N` or `E?.N`, or
1646+
- `N` is of the form `ItemX`, where `X` is a sequence of non-`0`-initiated decimal digits that could represent the position of a tuple element, and `X` does not represent the position of the element.
1647+
- Otherwise, the tuple type element shall be `T`.
16481648
16491649
A tuple expression is evaluated by evaluating each of its element expressions in order from left to right.
16501650
@@ -4422,7 +4422,7 @@ equality_expression
44224422
<!-- markdownlint-disable MD028 -->
44234423

44244424
<!-- markdownlint-enable MD028 -->
4425-
> *Note*: There is a grammar ambiguity between *type* and *constant_pattern* in a `relational_expression` on the right-hand-side of `is`; either might be a valid parse of a qualified identifier. In such a case, only if it fails to bind as a type (for compatibility with previous versions of the language), is it resolved to be the first thing found (which must be either a constant or a type). This ambiguity is only present on the right-hand side of such an expression.
4425+
> *Note*: There is a grammar ambiguity between *type* and *constant_pattern* in a `relational_expression` on the right-hand-side of `is`; either might be a valid parse of a qualified identifier. In such a case, only if it fails to bind as a type (for compatibility with previous versions of the language), is it resolved to be the first thing found (which must be either a constant or a type). This ambiguity is only present on the right-hand side of such an expression. *end note*
44264426
44274427
The `is` operator is described in [§12.14.12](expressions.md#121412-the-is-operator) and the `as` operator is described in [§12.14.13](expressions.md#121413-the-as-operator).
44284428

@@ -4751,16 +4751,16 @@ The tuple equality operators are applied pairwise to the elements of the tuple o
47514751

47524752
If each operand `x` and `y` of a `==` or `!=` operator is classified either as a tuple or as a value with a tuple type ([§8.3.11](types.md#8311-tuple-types)), the operator is a *tuple equality operator*.
47534753

4754-
If an operand `e` is classified as a tuple, the elements `e1...en` shall be the results of evaluating the element expressions of the tuple expression. Otherwise if `e` is a value of a tuple type, the elements shall be `t.Item1...t.Itemn` where `t` is the result of evaluating `e`.
4754+
If an operand `e` is classified as a tuple, the elements `e₁...eₙ` shall be the results of evaluating the element expressions of the tuple expression. Otherwise if `e` is a value of a tuple type, the elements shall be `t.Item1...t.Itemn` where `t` is the result of evaluating `e`.
47554755

4756-
The operands `x` and `y` of a tuple equality operator shall have the same arity, or a compile time error occurs. For each pair of elements `xi` and `yi`, the same equality operator shall apply, and shall yield a result of type `bool`, `dynamic`, a type that has an implicit conversion to `bool`, or a type that defines the `true` and `false` operators.
4756+
The operands `x` and `y` of a tuple equality operator shall have the same arity, or a compile time error occurs. For each pair of elements `xᵢ` and `yᵢ`, the same equality operator shall apply, and shall yield a result of type `bool`, `dynamic`, a type that has an implicit conversion to `bool`, or a type that defines the `true` and `false` operators.
47574757

47584758
The tuple equality operator `x == y` is evaluated as follows:
47594759

47604760
- The left side operand `x` is evaluated.
47614761
- The right side operand `y` is evaluated.
4762-
- For each pair of elements `xi` and `yi` in lexical order:
4763-
- The operator `xi == yi` is evaluated, and a result of type `bool` is obtained in the following way:
4762+
- For each pair of elements `xᵢ` and `yᵢ` in lexical order:
4763+
- The operator `xᵢ == yᵢ` is evaluated, and a result of type `bool` is obtained in the following way:
47644764
- If the comparison yielded a `bool` then that is the result.
47654765
- Otherwise if the comparison yielded a `dynamic` then the operator `false` is dynamically invoked on it, and the resulting `bool` value is negated with the logical negation operator (`!`).
47664766
- Otherwise, if the type of the comparison has an implicit conversion to `bool`, that conversion is applied.
@@ -4772,8 +4772,8 @@ The tuple equality operator `x != y` is evaluated as follows:
47724772

47734773
- The left side operand `x` is evaluated.
47744774
- The right side operand `y` is evaluated.
4775-
- For each pair of elements `xi` and `yi` in lexical order:
4776-
- The operator `xi != yi` is evaluated, and a result of type `bool` is obtained in the following way:
4775+
- For each pair of elements `xᵢ` and `yᵢ` in lexical order:
4776+
- The operator `xᵢ != yᵢ` is evaluated, and a result of type `bool` is obtained in the following way:
47774777
- If the comparison yielded a `bool` then that is the result.
47784778
- Otherwise if the comparison yielded a `dynamic` then the operator `true` is dynamically invoked on it, and the resulting `bool` value is the result.
47794779
- Otherwise, if the type of the comparison has an implicit conversion to `bool`, that conversion is applied.
@@ -6819,24 +6819,25 @@ When a property or indexer declared in a *struct_type* is the target of an assig
68196819
> ```csharp
68206820
> struct Point
68216821
> {
6822-
> int x, y;
6822+
> int x, y;
68236823
>
6824-
> public Point(int x, int y)
6825-
> {
6826-
> this.x = x;
6827-
> this.y = y;
6828-
> }
6824+
> public Point(int x, int y)
6825+
> {
6826+
> this.x = x;
6827+
> this.y = y;
6828+
> }
68296829
>
6830-
> public int X
6831-
> {
6832-
> get { return x; }
6833-
> set { x = value; }
6834-
> }
6830+
> public int X
6831+
> {
6832+
> get { return x; }
6833+
> set { x = value; }
6834+
> }
68356835
>
6836-
> public int Y {
6837-
> get { return y; }
6838-
> set { y = value; }
6839-
> }
6836+
> public int Y
6837+
> {
6838+
> get { return y; }
6839+
> set { y = value; }
6840+
> }
68406841
> }
68416842
>
68426843
> struct Rectangle
@@ -6920,17 +6921,18 @@ The ref assignment operator shall not read the storage location referenced by th
69206921
> public static ref readonly int M3() { ... }
69216922
> public static void Test()
69226923
> {
6923-
> int v = 42;
6924-
> ref int r1 = ref v; // OK, r1 refers to v, which has value 42
6925-
> r1 = ref M1(); // Error; M1 returns a value, not a reference
6926-
> r1 = ref M2(); // OK; makes an alias
6927-
> r1 = ref M2u(); // Error; lhs and rhs have different types
6928-
> r1 = ref M3(); // error; M3 returns a ref readonly, which r1 cannot honor
6929-
> ref readonly int r2 = ref v; // OK; make readonly alias to ref
6930-
> r2 = ref M2(); // OK; makes an alias, adding read-only protection
6931-
> r2 = ref M3(); // OK; makes an alias and honors the read-only
6932-
> r2 = ref (r1 = ref M2()); // OK; r1 is an alias to a writable variable,
6933-
> // r2 is an alias (with read-only access) to the same variable
6924+
> int v = 42;
6925+
> ref int r1 = ref v; // OK, r1 refers to v, which has value 42
6926+
> r1 = ref M1(); // Error; M1 returns a value, not a reference
6927+
> r1 = ref M2(); // OK; makes an alias
6928+
> r1 = ref M2u(); // Error; lhs and rhs have different types
6929+
> r1 = ref M3(); // error; M3 returns a ref readonly, which r1 cannot honor
6930+
> ref readonly int r2 = ref v; // OK; make readonly alias to ref
6931+
> r2 = ref M2(); // OK; makes an alias, adding read-only protection
6932+
> r2 = ref M3(); // OK; makes an alias and honors the read-only
6933+
> r2 = ref (r1 = ref M2()); // OK; r1 is an alias to a writable variable,
6934+
> // r2 is an alias (with read-only access)
6935+
> // to the same variable
69346936
> }
69356937
> ```
69366938
>

0 commit comments

Comments
 (0)