Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix tuple assignment#1366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
BillWagner wants to merge1 commit intodotnet:draft-v8
base:draft-v8
Choose a base branch
Loading
fromBillWagner:errors-in-tuple-assignment
Draft
Show file tree
Hide file tree
Changes fromall 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: 1 addition & 1 deletionstandard/conversions.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -345,7 +345,7 @@ In all cases, the rules ensure that a conversion is executed as a boxing convers

### 10.2.13 Implicit tuple conversions

An implicit conversion exists from a tupleexpression `E` to a tuple type `T` if `E` has the same arity as `T` and an implicit conversion exists from each elementin `E` to the corresponding elementtype in `T`. The conversion is performed by creating an instance of `T`’s corresponding `System.ValueTuple<...>` type, and initializing each of its fields in order from lefttoright by evaluatingthe correspondingtupleelementexpression of `E`, converting it to the corresponding elementtypeof `T` using the implicit conversion found, and initializing the field with the result.
An implicit conversion exists froman expression `E` witha tupletype `S` to a tuple type `T` if `S` has the same arity as `T` and an implicit conversion exists from each element type in `S`to the corresponding element typein `T`.
Copy link
Contributor

@jnm2jnm2Jul 3, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think I'm following, but just checking.Is there a tuple typeS for every tuple expression? For instance, does(default, default) have a tuple typeS in:

(object,object)x=(default,default);

jskeet reacted with thumbs up emoji

If an element name in the tuple expression does not match a corresponding element name in the tuple type, a warning shall be issued.

Expand Down
6 changes: 3 additions & 3 deletionsstandard/expressions.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,12 +33,12 @@ An ***instance accessor*** is a property access on an instance, an event access

### 12.2.2 Values of expressions

Most of the constructs that involve an expression ultimately require the expression to denote a ***value***. In such cases, if the actual expression denotes a namespace, a type, a method group, or nothing, a compile-time error occurs. However, if the expression denotes a property access, an indexer access, or a variable, the value of the property, indexer, or variable is implicitly substituted:
Most of the constructs that involve an expression ultimately require the expression to denote a ***value***. In such cases, if the actual expression denotes a namespace, a type, a method group, or nothing, a compile-time error occurs. However, if the expression denotes a property access, an indexer access,a tuple,or a variable, the value of the property, indexer, tuple, or variable is implicitly substituted:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why do we mention tuple expressions here, but we don't mention other kinds of expressions such as object creation expressions, array creation expressions, lambda expressions, and so on?

jskeet reacted with thumbs up emoji

- The value of a variable is simply the value currently stored in the storage location identified by the variable. A variable shall be considered definitely assigned ([§9.4](variables.md#94-definite-assignment)) before its value can be obtained, or otherwise a compile-time error occurs.
- The value of a property access expression is obtained by invoking the get accessor of the property. If the property has no get accessor, a compile-time error occurs. Otherwise, a function member invocation ([§12.6.6](expressions.md#1266-function-member-invocation)) is performed, and the result of the invocation becomes the value of the property access expression.
- The value of an indexer access expression is obtained by invoking the get accessor of the indexer. If the indexer has no get accessor, a compile-time error occurs. Otherwise, a function member invocation ([§12.6.6](expressions.md#1266-function-member-invocation)) is performed with the argument list associated with the indexer access expression, and the result of the invocation becomes the value of the indexer access expression.
- The value of a tuple expression is obtained byapplying an implicittupleconversion ([§10.2.13](conversions.md#10213-implicit-tuple-conversions)) to the type of the tuple expression. It is an error to obtain the value of a tuple expression that does not have a type.
- The value of a tuple expression isthe valueobtained byevaluating thetupleexpression (§12.8.6). It is an error to obtain the value of a tuple expression that does not have a type.

## 12.3 Static and Dynamic Binding

Expand DownExpand Up@@ -1611,7 +1611,7 @@ A tuple expression has a type if and only if each of its element expressions `Ei

A tuple expression is evaluated by evaluating each of its element expressions in order from left to right.

A tuple valuecan beobtained from a tuple expression byconverting itto a tuple type ([§10.2.13](conversions.md#10213-implicit-tuple-conversions)), by reclassifying it as a value ([§12.2.2](expressions.md#1222-values-of-expressions))) orbymakingit thetargetofa deconstructing assignment ([§12.21.2](expressions.md#12212-simple-assignment)).
A tuple valueisobtained from a tuple expression byevaluating itand storing the result in corresponding `System.ValueTuple<...>` type, and initializing each of its fields in order from left to rightbyevaluating the corresponding tuple element expression of `E`, convertingittothecorresponding element typeof`T` using the implicit conversion found, and initializing the field with the result.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

System.ValueTuple isn't mentioned anywhere else in this file. Shouldn't we be a bit more specific? There are wrinkles in how tuples map to the ValueTuple types. For instance, a tuple type(T1, T2, T3, T4, T5, T6, T7, T8) must be represented as nested ValueTuples, because the TRest type argument of a tuple must always itself be a nested tuple:ValueTuple<T1, T2, T3, T4, T5, T6, T7, ValueTuple<T8>>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I see that conversions.md does mentionValueTuple<...> a few times, but it doesn't explain the required recursive encoding.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I vaguely remember that we discussed how far we needed to go with that encoding aspect.

If we can avoid referring toValueTuple<...> in this section, it's likely to make our lives easier... even if it means doing a bit more work in 8.3.11 to effectively make that theonly place that needs to go into that detail. If we can say "logically there's a type with N fields" then we can make this line (in expressions.md) simpler.


> *Example*:
>
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp