Cannot cast TObject to TClientDataSet


we have recently updated our Pascal Script installation from GIT. After the update the following code snippet (cut down to only contain relevant lines) fails to compile at runtime:

procedure CastTest;
   lData    : TClientDataset;
   lObject  : TObject;
   lList    : TStringList;
   [... more code ...]
   if lObject is TStringList then begin
      lList := TStringList(lObject);
   end;   // Compiles!
   [... more code ...]
   if lObject is TClientDataset then begin
     lData := TClientDataset(lObject);
   end;  // does not Compile: Type mismatch error on the line above
   [... more code]

The class “TClientDataSet” is registered upon applications startup. This used to work for years now. But with the latest sources the snippet fails to compile.

Do you have any idea or hint why this code is not compiling?

Thanks in advance,

Are you by any chance using packages?

Both. It seems to compile when we use this snippet, for example while editing the source and compile it. But we also have a standalone-application that is used as a kind of “player” for the scripts and executes them. After loading a script in this application we are compiling the just loaded script and it fails with the message “Type mismatch”.

BTW: I have reverted the changes in GIT (to a version before 06 June) and it compiles in both situations.