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

Unexpected error for throw null!; #31294

Closed
TessenR opened this issue Nov 21, 2018 · 5 comments
Closed

Unexpected error for throw null!; #31294

TessenR opened this issue Nov 21, 2018 · 5 comments

Comments

@TessenR
Copy link

TessenR commented Nov 21, 2018

Version Used:

Branch C# 8.0: Nullable reference type (29 Oct 2018)
https://github.com/dotnet/csharplang/blob/master/proposals/nullable-reference-types.md
Latest commit 2f8fef by AlekseyTs:
Compare Nullable modifiers while comparing type symbols by default. (#30770)

Steps to Reproduce:

Compile the following code

class C
{
    void M1() => throw null;
    void M2() => throw null!;
}

https://sharplab.io/#v2:EYLgZgpghgLgrgJwgZwLQDk4BstWFiAJQkiQDsBjCAFQE8AHFAGhhCmRgB8ABAJgAIAwgFgAUAG8x/af24AWfgFkAjAAoAlPwC8APn4wAFggD2Ad35lsWANxSZ8pbw3a9hk+cs4AhLdEBfIA

Expected Behavior:

No errors or error with clear error message

Actual Behavior:

error CS0155: The type caught or thrown must be derived from System.Exception

@jcouv jcouv added this to the 16.0 milestone Nov 24, 2018
@jaredpar jaredpar added the Bug label Dec 6, 2018
@jaredpar
Copy link
Member

jaredpar commented Dec 6, 2018

Calling it out because it took me a second to see but it's the ! on the second throw null! that causes the issue here.

@jcouv
Copy link
Member

jcouv commented Dec 26, 2018

When we fix this, we should also test that x == null ! does the right thing (null should be recognized, despite the !). There may be other scenarios where null (or default) is treated specially, which we should verify.

For instance: #31297 (escape rules fail to see through !)

@jcouv
Copy link
Member

jcouv commented Jan 3, 2019

Here's third bug in this family: #31370 (delegate conversion doesn't recognize lambda with !).
Started a thread to discuss whether a general design could solve this.

@jcouv jcouv assigned jcouv and unassigned chsienki Jan 3, 2019
@jcouv jcouv modified the milestones: 16.0, 16.0.P2 Jan 3, 2019
@jcouv
Copy link
Member

jcouv commented Jan 3, 2019

FYI @jaredpar I self-assigned this bug and moved to preview2, since this family of problems can manifest as a crash.

@jcouv jcouv modified the milestones: 16.0.P2, 16.0.P3 Jan 9, 2019
@chsienki
Copy link
Contributor

Another from the same family: #31296

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

5 participants