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

Auto type casting in condition experssion assignment and etc. #13653

Closed
mojtabakaviani opened this issue Sep 7, 2016 · 4 comments
Closed

Auto type casting in condition experssion assignment and etc. #13653

mojtabakaviani opened this issue Sep 7, 2016 · 4 comments
Labels
Area-Language Design Language-C# Resolution-Won't Fix A real bug, but Triage feels that the issue is not impactful enough to spend time on.

Comments

@mojtabakaviani
Copy link

by default number is integer, so when assignment to smaller types need casting.
for example:

int a = 5, b = 6;
byte c = (byte)(a > b ? 1 : 0);

but 0,1 in byte range, Roslyn is intelligent and can auto casting.

byte c = a > b ? 1 : 0;
@dsaf
Copy link

dsaf commented Sep 7, 2016

Related to #1419?

@gafter
Copy link
Member

gafter commented Sep 7, 2016

If I understand this request, you are asking for "target typing" to see through "?:" expressions.

@mojtabakaviani
Copy link
Author

Yes, "?:" expressions is very good example.

@gafter
Copy link
Member

gafter commented Jan 8, 2018

I believe this would be a breaking language change, as the current specification for finding a common type among the operands of ?: and the proposed treatment using target typing could get different results. Since we don't want breaking changes, closing.

@gafter gafter closed this as completed Jan 8, 2018
@gafter gafter added the Resolution-Won't Fix A real bug, but Triage feels that the issue is not impactful enough to spend time on. label Jan 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Language Design Language-C# Resolution-Won't Fix A real bug, but Triage feels that the issue is not impactful enough to spend time on.
Projects
None yet
Development

No branches or pull requests

3 participants