csharpstandard icon indicating copy to clipboard operation
csharpstandard copied to clipboard

Type inference from element expressions within tuple literal arguments

Open cston opened this issue 11 months ago • 5 comments

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 avatar Jan 01 '25 02:01 cston

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.

cston avatar Jan 01 '25 02:01 cston

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

jskeet avatar Jan 22 '25 20:01 jskeet

@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 avatar Feb 09 '25 20:02 jnm2

Is this issue a duplicate of https://github.com/dotnet/csharpstandard/issues/1155, or something to cover simultaneously?

jnm2 avatar Feb 09 '25 20:02 jnm2

@jnm2 Done!

RexJaeschke avatar Feb 11 '25 16:02 RexJaeschke

Bill will have a look.

jskeet avatar Jun 11 '25 20:06 jskeet