MqlRates does not behave as documented, or I'm missing something

 

Here is the code:

#property strict

struct MyRates
{
   datetime time;         // Period start time
   double   open;         // Open price
   double   high;         // The highest price of the period
   double   low;          // The lowest price of the period
   double   close;        // Close price
   long     tick_volume;  // Tick volume
   int      spread;       // Spread
   long     real_volume;  // Trade volume
   int      Bar;
};

//+------------------------------------------------------------------+
//|   from https://docs.mql4.com/constants/structures/mqlrates
//+------------------------------------------------------------------+
//
//   struct MqlRates
//     {
//      datetime time;         // Period start time
//      double   open;         // Open price
//      double   high;         // The highest price of the period
//      double   low;          // The lowest price of the period
//      double   close;        // Close price
//      long     tick_volume;  // Tick volume
//      int      spread;       // Spread
//      long     real_volume;  // Trade volume
//     }
//

int OnInit()
{
   MqlRates  mqRates[1];

   int copied              = CopyRates(NULL,0,0,1,mqRates);

//+------------------------------------------------------------------+
//   from https://docs.mql4.com/basis/types/casting#casting_structure
//
//   Typecasting of Simple Structure Types
//   Data of the simple structures type can be assigned to each other only 
//   if all the members of both structures are of numeric types. In this 
//   case both operands of the assignment operation (left and right) must 
//   be of the structures type. The member-wise casting is not performed, 
//   a simple copying is done. If the structures are of different sizes, 
//   the number of bytes of the smaller size is copied. Thus the absence 
//   of union in MQL4 is compensated.
//+------------------------------------------------------------------+
//
   MyRates  mrRates        = mqRates[0];

   return(0);

}

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{
//---
   
}   

Here are the compilation results:

As per the code example at https://docs.mql4.com/basis/types/casting#casting_structure, a struct with 1 element can be assigned to a struct with 2 elements of different numeric data type.

So why can't a struct with 8 elements be assigned to a struct with the same 8 elements, same numeric data types, along with one additional numeric element?

Typecasting - Data Types - Language Basics - MQL4 Reference
Typecasting - Data Types - Language Basics - MQL4 Reference
  • docs.mql4.com
Typecasting - Data Types - Language Basics - MQL4 Reference