E2418 Type '%s' needs initialization - not allowed in variant record (Object Pascal)

From Appmethod Topics
Jump to: navigation, search

Go Up to Error and Warning Messages (Object Pascal) Index

Type needs initialization - not allowed in variant record. Variant records do not allow types that need initialization in their variant field list since each variant field references the same memory location. As an example, the following code will not compile because the array type needs to be initialized.


program Project3;

{$APPTYPE CONSOLE}

type
  TFoo = record
    case Boolean of
      True: (bar: Integer);
      False: (baz: array [0..2] of Integer);
  end;

end.