Skip to content
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

!! should be disallowed #29902

Closed
AlekseyTs opened this issue Sep 14, 2018 · 9 comments
Closed

!! should be disallowed #29902

AlekseyTs opened this issue Sep 14, 2018 · 9 comments

Comments

@AlekseyTs
Copy link
Contributor

        // PROTOTYPE(NullableReferenceTypes): Binder should report an error for `!!`.
        [Fact]
        public void SuppressNullableWarning_Multiple()
        {
            var source =
@"class C
{
    static void F(string? s)
    {
        G(default!!);
        G(s!!);
        G((s!)!);
    }
    static void G(string s)
    {
    }
}";
            var comp = CreateCompilation(
                new[] { source, NonNullTypesTrue, NonNullTypesAttributesDefinition },
                parseOptions: TestOptions.Regular8);
            comp.VerifyDiagnostics(/* ... */);
        }
@jcouv
Copy link
Member

jcouv commented Sep 17, 2018

Relates to #25372 (warn for un-necessary !)

@gafter
Copy link
Member

gafter commented Sep 18, 2018

Was there an LDM decision to support this?

@jcouv
Copy link
Member

jcouv commented Sep 18, 2018

I've updated the linked issue (warn for un-necessary !) after checking the LDM notes from last week. There was an explicit decision from LDM not to warn for such cases.
Regarding !!, there was no explicit decision from LDM yet.

@gafter
Copy link
Member

gafter commented Sep 19, 2018

I’m pretty sure that the decision not to warn included a decision not to error.

@jcouv
Copy link
Member

jcouv commented Sep 19, 2018

The rationale for not warning (namely so that copy&paste doesn't produce annoying warnings) doesn't apply to '!!' which would be an error in any context.

@gafter
Copy link
Member

gafter commented Sep 19, 2018

Wouldn’t copy-and-paste (e.g. to inline a variable) now possibly cause an annoying error?

@jcouv
Copy link
Member

jcouv commented Sep 19, 2018

Yes, that could happen.
Then, are you proposing to close this issue as "by design"?

@gafter
Copy link
Member

gafter commented Sep 19, 2018

Yes, I think it is permitted by design and not harmful.

@cston
Copy link
Member

cston commented Nov 2, 2018

@jcouv jcouv added Test Test failures in roslyn-CI and removed Bug labels Nov 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants