is
expression evaluating const
expression should be considered constant
#6925
-
EDIT: Championed in #6926 SummaryDespite being provided a constant expression, using an MotivationConditional compilation symbols, reliance on runtime constants deriving from conditional statements DescriptionYou cannot assign an public const int A = 4;
public const bool B = A is 4; // illegal, despite the result being available for constant evaluation
public const bool C = A is not 3 and < 1 or 5; // illegal too In the example above, Since patterns on the RHS of the pattern matching expression are always constant (as of now), the only limitation is the LHS also being a constant expression. ExampleConsider the following repro for determining where to publish a NuGet package. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I'll champion this. The current behavior is inconsistent with ternaries, which seems unfortunate. |
Beta Was this translation helpful? Give feedback.
I'll champion this. The current behavior is inconsistent with ternaries, which seems unfortunate.