Pattern Matching should respect [DoesNotReturn] and [DoesNotReturnIf] #7795
-
This (somewhat unexpectedly for me) produces a compiler error.
whereas using nearly-equivalent null checks works as expected
I assume this is because |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 31 replies
-
Obj is only assigned in a debug context, so this wouldn't be possible regardless. |
Beta Was this translation helpful? Give feedback.
-
The problem here is that "variable assignment" is a core language compilation error, and they don't want to tie it to certain attributes. There are proposals to make "does not return" a core language feature, which would allow your scenarios. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
@dazerdude The way to think about this is that these are different systems in the language design, with different goals. I understand your desire for them to be unified an to have uniform impact in the language feature-set.
All i can say is: that was considered, and explicitly rejected because the resultant language would actually have more negatives than positives over what we have today.
This is often a fundamental tension we have in lang design. Often times there is a preference for purity and uniformity. However, this butts heads with the need for pragmatic outcomes. NRT is fundamentally solving a different set of issues in a different fashion, due to many complex factors. Trying to d…