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

Fixed VS crash during implicit conversion of null object in nullable walker #45974

Merged
merged 2 commits into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5537,7 +5537,7 @@ private Conversion GenerateConversionForConditionalOperator(BoundExpression sour
private static Conversion GenerateConversion(Conversions conversions, BoundExpression sourceExpression, TypeSymbol sourceType, TypeSymbol destinationType, bool fromExplicitCast, bool extensionMethodThisArgument)
{
HashSet<DiagnosticInfo> useSiteDiagnostics = null;
bool useExpression = UseExpressionForConversion(sourceExpression);
bool useExpression = sourceType is null || UseExpressionForConversion(sourceExpression);
if (extensionMethodThisArgument)
{
return conversions.ClassifyImplicitExtensionMethodThisArgConversion(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128501,5 +128501,36 @@ internal interface IB : IA { }
var comp = CreateCompilation(source);
comp.VerifyEmitDiagnostics();
}

[Fact]
[WorkItem(45862, "https://github.com/dotnet/roslyn/issues/45862")]
public void Issue_45862()
{
var source =
@"#nullable enable

class C
{
void M()
{
_ = 0 switch
{
0 =
_ = null,
};
}
}";
var comp = CreateCompilation(source);
comp.VerifyEmitDiagnostics(
// (9,15): error CS1003: Syntax error, '=>' expected
// 0 =
Diagnostic(ErrorCode.ERR_SyntaxError, "=").WithArguments("=>", "=").WithLocation(9, 15),
// (9,15): error CS1525: Invalid expression term '='
// 0 =
Diagnostic(ErrorCode.ERR_InvalidExprTerm, "=").WithArguments("=").WithLocation(9, 15),
// (10,13): error CS8183: Cannot infer the type of implicitly-typed discard.
// _ = null,
Diagnostic(ErrorCode.ERR_DiscardTypeInferenceFailed, "_").WithLocation(10, 13));
}
}
}