GithubHelp home page GithubHelp logo

Comments (6)

controlflow avatar controlflow commented on July 21, 2024

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 c?.M() expression. Is it T (I think so) or void?

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 T type (and other non-liftable types) into void type?

from roslyn.

theoy avatar theoy commented on July 21, 2024

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.

from roslyn.

theoy avatar theoy commented on July 21, 2024

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. 😄

from roslyn.

controlflow avatar controlflow commented on July 21, 2024

😉

from roslyn.

VSadov avatar VSadov commented on July 21, 2024

It is allowed to have void returning conditional accesses in statement expression scenarios. Scenarios like resource?.Dispose() or event1?.Invoke() seem very useful.
Since we agree on allowing void in such scenarios, it makes sense to remove nullability requirement as well.

from roslyn.

AlekseyTs avatar AlekseyTs commented on July 21, 2024

I believe this issue has been addressed already. @VladimirReshetnikov, please verify and close if appropriate.

from roslyn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.