-
Notifications
You must be signed in to change notification settings - Fork 1k
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
DoesNotReturnAttribute should affect definite assignment #2555
Comments
Also related: #739 |
When we talked about this attribute during CoreFX design, we were pretty explicit that an attribute alone should not affect code generation and definite analysis in this manner. If we ever want to go down the route of affecting definite assignment, we will need to introduce new syntax, likely a conditional keyword such as |
Then wouldn't now be the right time to add this feature, rather than have two equivalent syntaxes? Or is it too close to C# 8 to do this? |
To be clear, this wouldn't be two equivalent syntaxes. One would likely supersede the other, with the explicit As to the timing, yes, I think we're likely too close to C# 8 to make such a change. |
I believe this is where the conversation started during the API review livestream: https://youtu.be/zAhOxraBsi0?t=3665 (almost 20 min long) |
Closing in favour of #538, as this isn't planned in the C# 8 timeframe anyway. |
Closed, but thought it was worth mentioning for anyone else who sees this, the addition of |
The compiler is introducing a new attribute
DoesNotReturn
that will affect nullability analysis.I think it would make sense for the compiler to enforce this strictly, and for it to affect definite assignment as well.
It is possible that someone using a different .NET language/old compiler could add this attribute to a method which does in fact return. However this will only lead to undefined behaviour, not unsafe behaviour, because the C# compiler zeroes out the stack before calling a method. I believe that the benefits therefore outway the risk.
See also: #538
The text was updated successfully, but these errors were encountered: