Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions standard/conversions.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
- Implicit tuple conversions ([§10.2.13](conversions.md#10213-implicit-tuple-conversions))
- Default literal conversions ([§10.2.16](conversions.md#10216-default-literal-conversions))
- Implicit throw conversions ([§10.2.17](conversions.md#10217-implicit-throw-conversions))
- Anonymous function type conversions (§anon-func-type-conversion)

Check failure on line 66 in standard/conversions.md

View workflow job for this annotation

GitHub Actions / TOC and Anchor updater

standard/conversions.md#L66

TOC002::`§anon-func-type-conversion` not found

Implicit conversions can occur in a variety of situations, including function member invocations ([§12.6.6](expressions.md#1266-function-member-invocation)), cast expressions ([§12.9.8](expressions.md#1298-cast-expressions)), and assignments ([§12.24](expressions.md#1224-assignment-operators)).

Expand Down Expand Up @@ -117,8 +117,6 @@

In most cases, an identity conversion has no effect at runtime. However, since floating point operations may be performed at higher precision than prescribed by their type ([§8.3.7](types.md#837-floating-point-types)), assignment of their results may result in a loss of precision, and explicit casts are guaranteed to reduce precision to what is prescribed by the type ([§12.9.8](expressions.md#1298-cast-expressions)).

There is an identity conversion between `nint` and `System.IntPtr`, and between `nuint` and `System.UIntPtr`.

For the compound types array, nullable type, constructed type, and tuple, there is an identity conversion between native integers ([§8.3.6](types.md#836-integral-types)) and their underlying types.

### 10.2.3 Implicit numeric conversions
Expand Down Expand Up @@ -150,7 +148,7 @@

An implicit interpolated string conversion permits an *interpolated_string_expression* ([§12.8.3](expressions.md#1283-interpolated-string-expressions)) to be converted to `System.IFormattable` or `System.FormattableString` (which implements `System.IFormattable`). When this conversion is applied, a string value is not composed from the interpolated string. Instead an instance of `System.FormattableString` is created, as further described in [§12.8.3](expressions.md#1283-interpolated-string-expressions).

For any type `T` that is an applicable interpolated string handler type (§custInterpStrExpCustHandling), there exists an implicit interpolated string handler conversion to `T` from a non-constant *ISE* ([§12.8.3](expressions.md#1283-interpolated-string-expressions)). This conversion exists, regardless of whether errors are found later when attempting to lower the interpolation using the handler pattern. This ensures that there are predictable and useful errors, and that runtime behavior doesn't change based on the content of an interpolated string.

Check failure on line 151 in standard/conversions.md

View workflow job for this annotation

GitHub Actions / TOC and Anchor updater

standard/conversions.md#L151

TOC002::`§custInterpStrExpCustHandling` not found

### 10.2.6 Implicit nullable conversions

Expand Down Expand Up @@ -389,7 +387,7 @@

### 10.2.15 Anonymous function conversions and method group conversions

Anonymous functions and method groups do not have types in and of themselves, but they may have a natural type (§anon-func-type). They may be implicitly converted to delegate types. Additionally, some lambda expressions may be implicitly converted to expression tree types. Anonymous function conversions are described in more detail in [§10.7](conversions.md#107-anonymous-function-conversions) and method group conversions in [§10.8](conversions.md#108-method-group-conversions).

Check failure on line 390 in standard/conversions.md

View workflow job for this annotation

GitHub Actions / TOC and Anchor updater

standard/conversions.md#L390

TOC002::`§anon-func-type` not found

### 10.2.16 Default literal conversions

Expand Down
3 changes: 2 additions & 1 deletion standard/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@
```csharp
int operator *(int x, int y);
uint operator *(uint x, uint y);
nint operator *(nint x, nint y);
nuint operator *(nuint x, nuint y);
long operator *(long x, long y);
ulong operator *(ulong x, ulong y);
float operator *(float x, float y);
Expand All @@ -298,7 +300,6 @@

> *Example*: For the operation `b * s`, where `b` is a `byte` and `s` is a `short`, overload resolution selects `operator *(int, int)` as the best operator. Thus, the effect is that `b` and `s` are converted to `int`, and the type of the result is `int`. Likewise, for the operation `i * d`, where `i` is an `int` and `d` is a `double`, `overload` resolution selects `operator *(double, double)` as the best operator. *end example*


**End of informative text.**

#### 12.4.7.2 Unary numeric promotions
Expand Down Expand Up @@ -1542,7 +1543,7 @@

1. If the target of an assignment or method-call argument has type `string`, the expression is processed by the default interpolated string handler, `System.Runtime.CompilerServices.DefaultInterpolatedStringHandler`, and the result has type `string`.
1. If the target of an assignment or method-call argument has type `System.IFormattable` or `System.FormattableString`, a string value is not composed from the interpolated string. Instead an instance of `System.FormattableString` is created.
1. If the target of an assignment or method-call argument has a custom interpolated string handler (§custInterpStrExpHandler) type, then

Check failure on line 1546 in standard/expressions.md

View workflow job for this annotation

GitHub Actions / TOC and Anchor updater

standard/expressions.md#L1546

TOC002::`§custInterpStrExpHandler` not found

- If the interpolated string contains no interpolations, the expression is processed as if the target type was `string`.
- Otherwise, the expression is processed by the custom interpolated string handler and the result has that custom interpolated string handler’s type.
Expand Down
8 changes: 4 additions & 4 deletions standard/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ A struct type is a value type that can declare constants, fields, methods, prope

### 8.3.5 Simple types

Except for `nint` and `nuint`, the simple types are aliases for predefined `struct` types in the `System` namespace, as described in the table below.
The simple types are aliases for predefined `struct` types in the `System` namespace, as described in the table below.

**Keyword** | **Aliased type**
----------- | ------------------
Expand All @@ -285,8 +285,8 @@ Except for `nint` and `nuint`, the simple types are aliases for predefined `stru
`ushort` | `System.UInt16`
`int` | `System.Int32`
`uint` | `System.UInt32`
`nint` | none; see below
`nuint` | none; see below
`nint` | `System.IntPtr`
`nuint` | `System.UIntPtr`
`long` | `System.Int64`
`ulong` | `System.UInt64`
`char` | `System.Char`
Expand All @@ -295,7 +295,7 @@ Except for `nint` and `nuint`, the simple types are aliases for predefined `stru
`bool` | `System.Boolean`
`decimal` | `System.Decimal`

Every simple type has members. Each simple type that is an alias for a predefined struct type, has that struct type’s members.
Every simple type has members. Each simple type has its aliased struct type’s members.

> *Example*: `int` has any implementation-specific members declared in `System.Int32` and the members (required and implementation specific) inherited from `System.Object`, and the following statements are permitted:
>
Expand Down
8 changes: 7 additions & 1 deletion standard/unsafe-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -787,22 +787,28 @@ In an unsafe context, the `+` operator ([§12.13.5](expressions.md#12135-additio
```csharp
T* operator +(T* x, int y);
T* operator +(T* x, uint y);
T* operator +(T* x, nint y);
T* operator +(T* x, nuint y);
T* operator +(T* x, long y);
T* operator +(T* x, ulong y);
T* operator +(int x, T* y);
T* operator +(uint x, T* y);
T* operator +(nint x, T* y);
T* operator +(nuint x, T* y);
T* operator +(long x, T* y);
T* operator +(ulong x, T* y);
T* operator –(T* x, int y);
T* operator –(T* x, uint y);
T* operator -(T* x, nint y);
T* operator -(T* x, nuint y);
T* operator –(T* x, long y);
T* operator –(T* x, ulong y);
long operator –(T* x, T* y);
```

There are no predefined operators for pointer addition or subtraction with native integer ([§8.3.6](types.md#836-integral-types)) offsets. Instead, `nint` and `nuint` values shall be promoted to `long` and `ulong`, respectively, with pointer arithmetic using the predefined operators for those types.

Given an expression `P` of a data pointer type `T*` and an expression `N` of type `int`, `uint`, `long`, or `ulong`, the expressions `P + N` and `N + P` compute the pointer value of type `T*` that results from adding `N * sizeof(T)` to the address given by `P`. Likewise, the expression `P – N` computes the pointer value of type `T*` that results from subtracting `N * sizeof(T)` from the address given by `P`.
Given an expression `P` of a data pointer type `T*` and an expression `N` of type `int`, `uint`, `nint`, `nuint`, `long`, or `ulong`, the expressions `P + N` and `N + P` compute the pointer value of type `T*` that results from adding `N * sizeof(T)` to the address given by `P`. Likewise, the expression `P – N` computes the pointer value of type `T*` that results from subtracting `N * sizeof(T)` from the address given by `P`.

Given two expressions, `P` and `Q`, of a data pointer type `T*`, the expression `P – Q` computes the difference between the addresses given by `P` and `Q` and then divides that difference by `sizeof(T)`. The type of the result is always `long`. In effect, `P - Q` is computed as `((long)(P) - (long)(Q)) / sizeof(T)`.

Expand Down
Loading