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

Champion: target-typed conditional expression (VS 16.8, .NET 5) #2460

Open
3 of 5 tasks
Tracked by #829
gafter opened this issue Apr 22, 2019 · 8 comments
Open
3 of 5 tasks
Tracked by #829

Champion: target-typed conditional expression (VS 16.8, .NET 5) #2460

gafter opened this issue Apr 22, 2019 · 8 comments
Assignees
Labels
Design Review Implemented Needs ECMA Spec This feature has been implemented in C#, but still needs to be merged into the ECMA specification Proposal champion Smallish Feature
Milestone

Comments

@gafter
Copy link
Member

gafter commented Apr 22, 2019

This was split from #2389 and is being treated as a separate feature

For a conditional expression c ? e1 : e2, when there is no common type for e1 and e2, we define a new conditional expression conversion that permits an implicit conversion from the conditional expression to any type T for which there is a conversion-from-expression from e1 to T and also from e2 to T. It is an error if a conditional expression neither has a common type between e1 and e2 nor is subject to a conditional expression conversion.

Relates to #2701 (target-typed new[])

@YairHalberstadt
Copy link
Contributor

Could this also apply to the ?? operator as well?

@gafter
Copy link
Member Author

gafter commented Apr 23, 2019

@YairHalberstadt This proposal is for the ?: operator only.

@YairHalberstadt
Copy link
Contributor

YairHalberstadt commented Apr 23, 2019

@gafter
I understand, but is there any reason not to do the equavelent for ??. I would find it extremely useful.
Should I open a new proposal for it?

@gafter
Copy link
Member Author

gafter commented Apr 24, 2019

I don’t know. I have not thought about doing something for ??. The main reason not to do something in general is the balance between limited resources and limited benefit.

@YairHalberstadt
Copy link
Contributor

If I were to offer to implement it, would that make a difference?

@gafter
Copy link
Member Author

gafter commented Apr 25, 2019

@YairHalberstadt Without a proposed specification, I have no idea. I think we'd want to review the proposed specification to decide if it were something we want or not.

@YairHalberstadt
Copy link
Contributor

I have suggested a specification at #2473

@gafter gafter modified the milestones: 8.0 candidate, 8.X candidate Apr 29, 2019
@ErikSchierboom
Copy link
Contributor

Would love to see this feature added!

@jcouv jcouv changed the title Champion: target-typed conditional expression Champion: target-typed conditional expression (VS 16.8, .NET 5) Sep 1, 2020
@MadsTorgersen MadsTorgersen modified the milestones: 9.0 candidate, 9.0 Sep 9, 2020
@333fred 333fred added the Implemented Needs ECMA Spec This feature has been implemented in C#, but still needs to be merged into the ECMA specification label Oct 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Design Review Implemented Needs ECMA Spec This feature has been implemented in C#, but still needs to be merged into the ECMA specification Proposal champion Smallish Feature
Projects
None yet
Development

No branches or pull requests

5 participants