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

Type inference from element expressions within tuple literal arguments #1244

Open
cston opened this issue Jan 1, 2025 · 5 comments
Open
Milestone

Comments

@cston
Copy link
Member

cston commented Jan 1, 2025

The Roslyn compiler allows type inference from element expressions within tuple literal arguments.

F((1, null), (default, "")); // ok: F<int, string>()

static void F<T, U>((T, U) x, (T, U) y) { }

However, it looks like 12.6.3 Type inference only covers inference from the tuple argument type, not from the tuple element expressions.

@cston
Copy link
Member Author

cston commented Jan 1, 2025

FWIW, for collection expressions there is a similar requirement, and the collection expressions proposal extracts the rules from the first phase to an input type inference section to allow adding a recursive inference rule for collection expression elements.

@jnm2 jnm2 added the meeting: discuss This issue should be discussed at the next TC49-TG2 meeting label Jan 20, 2025
@jskeet
Copy link
Contributor

jskeet commented Jan 22, 2025

Thanks for this - we will (each) take a look when we are feeling brave enough to venture once more into the type inference spec.

@RexJaeschke RexJaeschke removed the meeting: discuss This issue should be discussed at the next TC49-TG2 meeting label Jan 22, 2025
@jnm2
Copy link
Contributor

jnm2 commented Feb 9, 2025

@RexJaeschke Given that this affects the v8 spec (as well as the v7 spec), would it be helpful to milestone this to keep track of everything that needs to be done for the current spec version?

@jnm2
Copy link
Contributor

jnm2 commented Feb 9, 2025

Is this issue a duplicate of #1155, or something to cover simultaneously?

@RexJaeschke RexJaeschke added this to the Pre-C# 8.0 milestone Feb 11, 2025
@RexJaeschke
Copy link
Contributor

@jnm2 Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants