bool as governing type of switch statement is directly prohibited by C# specification. There are a number of cases when Microsoft C# compiler behavour differs from specification.
Moreover, there are non-evident reasons why bool is prohibited. Hint - how op_True and op_False operators should be treated? And what should be done if they do not match boolean logic?
bool as governing type of switch statement is directly prohibited by C# specification. There are a number of cases when Microsoft C# compiler behavour differs from specification.
Nat
I don't have a fix for you but shouldn't you just be using:
if (x) {
//
}
else {
//
}
instead of the switch statement?
Perhaps the guys at JetBrains never considered using a bool in a switch
so they did not include it as an allowed type.
In article <5070223.1170773115841.JavaMail.itn@is.intellij.net>,
no_reply@jetbrains.com says...
I know. I didn't write that piece of code though :)
Hello Nat,
unlilke C and C++ boolean are not integral types in C#
But C# can compile this code. I'm just saying that R# should not error out anything that C# compiler can compile.
Hello,
We appreciate your feedback.
The corresponding JIRA request has been created, and you are welcome to monitor
its status at http://www.jetbrains.net/jira/browse/RSRP-36019.
Best regards,
- Development Team.
bool as governing type of switch statement is directly prohibited by C#
specification.
There are a number of cases when Microsoft C# compiler behavour differs from
specification.
--
Eugene Pasynkov
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"Nat" <no_reply@jetbrains.com> wrote in message
news:5070223.1170773115841.JavaMail.itn@is.intellij.net...
>
>
Moreover, there are non-evident reasons why bool is prohibited. Hint - how
op_True and op_False operators should be treated? And what should be done if
they do not match boolean logic?
--
Eugene Pasynkov
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"Eugene Pasynkov (JetBrains)" <Eugene.Pasynkov@jetbrains.com> wrote in
message news:erh0o1$hum$1@is.intellij.net...
>
>> bool x = true;
>>
>> switch (_x_)
>> {
>> case true: break;
>> case false: break;
>> }
>>
>> it says "Value of integral type expected"
>