Extend [DoesNotReturn] attribute impact to execution flow analysis #7869
Replies: 2 comments 12 replies
-
As mentioned in the previous discussion, this is covered by #538. |
Beta Was this translation helpful? Give feedback.
-
It is enough to throw an exception after calling a method with the [DoesNotReturn] attribute. This is what I suggest above. // Call a method with the [DoesNotReturn] attribute
Throw();
// Will be compiled into the following code
Throw();
UnreachableFlowException.Throw(); // Protect from incorrect [DoesNotReturn] attribute. This method is included in the standard library and is well-known to the compiler. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The compiler can compile a switch expression that throws an exception directly.
However, the compiler can not compile a switch expression that calls a method with the [DoesNotReturn] attribute.
I suggest extending [DoesNotReturn] attribute impact to execution flow analysis. This will allow us to compile the code that calls the method that always throws an exception.
This will protect the execution flow from setting the [DoesNotReturn] attribute incorrectly.
Related discussions
Beta Was this translation helpful? Give feedback.
All reactions