You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: standard/expressions.md
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1111,10 +1111,11 @@ Given `int i = 10;`, according to [§12.6.4.2](expressions.md#12642-applicable-f
1111
1111
1112
1112
#### 12.6.4.5 Better conversion from expression
1113
1113
1114
-
Given an implicit conversion `C₁` that converts from an expression `E` to a type `T₁`, and an implicit conversion `C₂` that converts from an expression `E` to a type `T₂`, `C₁` is a ***better conversion*** than `C₂` if one of the following holds:
1114
+
Given an implicit conversion `C₁` that converts from an expression `E` to a type `T₁`, and an implicit conversion `C₂` that converts from an expression `E` to a type `T₂`, `C₁` is a ***better conversion*** than `C₂` if `E` does not exactly match `T₂` and at least one of the following holds:
1115
1115
1116
1116
- `E` exactly matches `T₁` and `E` does not exactly match `T₂` ([§12.6.4.6](expressions.md#12646-exactly-matching-expression))
1117
-
- `E` exactlymatchesbothorneitherof `T₁` and `T₂`, and `T₁` isabetterconversiontargetthan `T₂` ([§12.6.4.7](expressions.md#12647-better-conversion-target))
- `E` exactlymatchesbothorneitherof `T₁` and `T₂`, and `T₁` isabetterconversiontargetthan `T₂` ([§12.6.4.7](expressions.md#12647-better-conversion-target)) andeither `C₁` and `C₂` arebothconditionalexpressionconversionsorneitherisaconditionalexpressionconversion.
1118
1119
- `E` isamethodgroup ([§12.2](expressions.md#122-expression-classifications)), `T₁` iscompatible ([§21.4](delegates.md#214-delegate-compatibility)) withthesinglebestmethodfromthemethodgroupfor conversion `C₁`, and `T₂` is not compatible with the single best method from the method group for conversion `C₂`
1119
1120
1120
1121
#### 12.6.4.6 Exactly matching expression
@@ -3735,7 +3736,7 @@ cast_expression
3735
3736
;
3736
3737
```
3737
3738
3738
-
A *cast_expression* of the form `(T)E`, where `T` is a type and `E` is a *unary_expression*, performs an explicit conversion ([§10.3](conversions.md#103-explicit-conversions)) of the value of `E` to type `T`. If no explicit conversion exists from `E` to `T`, a binding-time error occurs. Otherwise, the result is the value produced by the explicit conversion. The result is always classified as a value, even if `E` denotes a variable.
3739
+
A *cast_expression* of the form `(T)E`, where `T` is a type and `E` is a *unary_expression*, performs an explicit conversion ([§10.3](conversions.md#103-explicit-conversions)) of the value of `E` to type `T`. In the presence of a conditional expression conversion (§imp-cond-expr-conv) there may be more than one possible conversion from `E` to `T`, in which case, the conditional expression conversion shall only be used as a last resort. If no explicit conversion exists from `E` to `T`, a binding-time error occurs. Otherwise, the result is the value produced by the explicit conversion. The result is always classified as a value, even if `E` denotes a variable.
3739
3740
3740
3741
The grammar for a *cast_expression* leads to certain syntactic ambiguities.
3741
3742
@@ -5204,7 +5205,7 @@ If `ref` is present:
5204
5205
If `ref` is not present, the second and third operands, `x` and `y`, of the `?:` operator control the type of the conditional expression:
5205
5206
5206
5207
- If `x` has type `X` and `y` has type `Y` then,
5207
-
- If an identity conversion exists between `X` and `Y`, then the result is the best common type of a set of expressions ([§12.6.3.16](expressions.md#126316-finding-the-best-common-type-of-a-set-of-expressions)). If either type is `dynamic`, type inference prefers `dynamic` ([§8.7](types.md#87-the-dynamic-type)). If either type is a tuple type ([§8.3.11](types.md#8311-tuple-types)), type inference includes the element names when the element names in the same ordinal position match in both tuples.
5208
+
- If an identity conversion exists between `X` and `Y`, then the result is the best common type of a set of expressions ([§12.6.3.16](expressions.md#126316-finding-the-best-common-type-of-a-set-of-expressions)). ***placeholder for words somehow referring to “12.6.4.5 Better conversion from expression.”***If either type is `dynamic`, type inference prefers `dynamic` ([§8.7](types.md#87-the-dynamic-type)). If either type is a tuple type ([§8.3.11](types.md#8311-tuple-types)), type inference includes the element names when the element names in the same ordinal position match in both tuples.
5208
5209
- Otherwise, if an implicit conversion ([§10.2](conversions.md#102-implicit-conversions)) exists from `X` to `Y`, but not from `Y` to `X`, then `Y` is the type of the conditional expression.
5209
5210
- Otherwise, if an implicit enumeration conversion ([§10.2.4](conversions.md#1024-implicit-enumeration-conversions)) exists from `X` to `Y`, then `Y` is the type of the conditional expression.
5210
5211
- Otherwise, if an implicit enumeration conversion ([§10.2.4](conversions.md#1024-implicit-enumeration-conversions)) exists from `Y` to `X`, then `X` is the type of the conditional expression.
0 commit comments