Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning CS8123 is misleading if there is no element name in the target type #18169

Closed
jskeet opened this issue Mar 25, 2017 · 2 comments
Closed
Assignees
Labels
Area-Compilers Concept-Diagnostic Clarity The issues deals with the ease of understanding of errors and warnings. Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Milestone

Comments

@jskeet
Copy link

jskeet commented Mar 25, 2017

Version Used: 2.0.0.61501

Steps to Reproduce:

Compile this code:

(int, int) t = (pointless: 10, 20);

Expected Behavior:

A warning along the lines of:

The tuple element name 'pointless' is ignored because no name is specified by the corresponding element in the target type '(int, int)'

Actual Behavior:

The tuple element name 'pointless' is ignored because a different name is specified by the target type '(int, int)'

The actual error message is misleading because a different name isn't specified - instead, no name is specified.

It's fine for this to be a warning, but it would be nice if the message were clearer. Unfortunately my guess is that in order to have a different message between this and the situation where there really is a different name, they have to be different warning numbers - and that may count as a breaking change. (I'm not sure what the C# team policy is there.) In that case, we might need a single warning message that covers both situations. For example:

The tuple element name 'pointless' is ignored because the corresponding element in the target type '(int, int)' does not specify the same name.

That's definitely not as nice as having two different warnings though, IMO.

@jcouv jcouv added the Concept-Diagnostic Clarity The issues deals with the ease of understanding of errors and warnings. label Apr 5, 2017
@jcouv jcouv self-assigned this Apr 5, 2017
@jcouv
Copy link
Member

jcouv commented Apr 6, 2017

I didn't want to introduce two different diagnostics, but updated message. Hopefully that should minimize the confusion.
warning CS8123: The tuple element name 'b' is ignored because a different name or no name is specified by the target type '(int a, int)'.

@jcouv
Copy link
Member

jcouv commented Apr 6, 2017

Closed by #18454

@jcouv jcouv closed this as completed Apr 6, 2017
@jcouv jcouv added this to the 15.3 milestone Apr 6, 2017
@jcouv jcouv added the Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented label Apr 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Concept-Diagnostic Clarity The issues deals with the ease of understanding of errors and warnings. Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Projects
None yet
Development

No branches or pull requests

3 participants