-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Unable to compile conditional access expression in context of expression-bodied void method/lambda expression #11
Comments
And from language design perspective: this whole idea of allowing more conditional access expressions to compile in context where value is ignored (is it defined by spec?) feels awkward and ad-hoc. What kind of scenarios this solves? As a tooling developer, I have to disable 'introduce variable' refactoring for such expressions and this may be confusing for developers. Also I have no idea of what semantic model should tell about type of such Maybe (I'm not sure), it's better to allow such calls of methods with non-liftable return types in any context, but simply lift unconstrained |
I think the goal is more to allow it in contexts where the normal '.' dispatching is allowed - for example method calls that return a value are allowed as statement expressions. The user intention is to find places where a NullReferenceException would normally occur and instead allow for a graceful null-propagation (or at least a lack of throwing) to occur. |
By the way, great catch! I'm thrilled for all of the valuable points that you've been able to help us find as we are trying to land Roslyn v1. 😄 |
😉 |
It is allowed to have void returning conditional accesses in statement expression scenarios. Scenarios like resource?.Dispose() or event1?.Invoke() seem very useful. |
I believe this issue has been addressed already. @VladimirReshetnikov, please verify and close if appropriate. |
…vColumns remove Roslyns ItemOrigin and Repository column definitions
Related commit: dd8f041
I'm expecting it also to work with void methods in expression-bodied form, as well as void lambda expressions:
The text was updated successfully, but these errors were encountered: