@@ -5501,41 +5501,5 @@ static void Main()
55015501 ) ;
55025502 var compVerifier = CompileAndVerify ( compilation , expectedOutput : expectedOutput ) ;
55035503 }
5504-
5505- [ Fact , WorkItem ( 44398 , "https://github.com/dotnet/roslyn/issues/44398" ) ]
5506- public void MismatchedExpressionPattern ( )
5507- {
5508- var source =
5509- @"class C
5510- {
5511- static void M(int a)
5512- {
5513- if (a is a is > 0 and < 500) { }
5514- if (true is < 0) { }
5515- if (true is 0) { }
5516- }
5517- }" ;
5518- var compilation = CreateCompilation ( source , parseOptions : TestOptions . RegularWithPatternCombinators ) ;
5519- compilation . VerifyDiagnostics (
5520- // (5,18): error CS0150: A constant value is expected
5521- // if (a is a is > 0 and < 500) { }
5522- Diagnostic ( ErrorCode . ERR_ConstantExpected , "a" ) . WithLocation ( 5 , 18 ) ,
5523- // (5,25): error CS0029: Cannot implicitly convert type 'int' to 'bool'
5524- // if (a is a is > 0 and < 500) { }
5525- Diagnostic ( ErrorCode . ERR_NoImplicitConv , "0" ) . WithArguments ( "int" , "bool" ) . WithLocation ( 5 , 25 ) ,
5526- // (5,33): error CS0029: Cannot implicitly convert type 'int' to 'bool'
5527- // if (a is a is > 0 and < 500) { }
5528- Diagnostic ( ErrorCode . ERR_NoImplicitConv , "500" ) . WithArguments ( "int" , "bool" ) . WithLocation ( 5 , 33 ) ,
5529- // (6,21): error CS8781: Relational patterns may not be used for a value of type 'bool'.
5530- // if (true is < 0) { }
5531- Diagnostic ( ErrorCode . ERR_UnsupportedTypeForRelationalPattern , "< 0" ) . WithArguments ( "bool" ) . WithLocation ( 6 , 21 ) ,
5532- // (6,23): error CS0029: Cannot implicitly convert type 'int' to 'bool'
5533- // if (true is < 0) { }
5534- Diagnostic ( ErrorCode . ERR_NoImplicitConv , "0" ) . WithArguments ( "int" , "bool" ) . WithLocation ( 6 , 23 ) ,
5535- // (7,21): error CS0029: Cannot implicitly convert type 'int' to 'bool'
5536- // if (true is 0) { }
5537- Diagnostic ( ErrorCode . ERR_NoImplicitConv , "0" ) . WithArguments ( "int" , "bool" ) . WithLocation ( 7 , 21 )
5538- ) ;
5539- }
55405504 }
55415505}
0 commit comments