public static void CheckConstant(ConstantExpression value, bool isRelational)
        {
            if (value.Value == null)
            {
                if (isRelational)
                {
                    throw Error.CannotUseNullValueInRelationalPattern();
                }

                return;
            }

            if (value.Type.IsNullableType() && value.Value != null)
            {
                throw Error.InvalidPatternConstantType(value.Type);
            }

            if (value.Type == typeof(IntPtr) || value.Type == typeof(UIntPtr))
            {
                return;
            }

            switch (Type.GetTypeCode(value.Type.GetNonNullableType()))
            {
            case TypeCode.Char:
            case TypeCode.SByte:
            case TypeCode.Byte:
            case TypeCode.Int16:
            case TypeCode.UInt16:
            case TypeCode.Int32:
            case TypeCode.UInt32:
            case TypeCode.Int64:
            case TypeCode.UInt64:
            case TypeCode.Decimal:
                break;

            case TypeCode.Single:
                if (isRelational && float.IsNaN((float)value.Value))
                {
                    throw Error.CannotUsePatternConstantNaN();
                }
                break;

            case TypeCode.Double:
                if (isRelational && double.IsNaN((double)value.Value))
                {
                    throw Error.CannotUsePatternConstantNaN();
                }
                break;

            case TypeCode.Boolean:
            case TypeCode.String:
                if (isRelational)
                {
                    throw Error.InvalidRelationalPatternConstantType(value.Type);
                }
                break;

            default:
                throw Error.InvalidPatternConstantType(value.Type);
            }
        }