Jump to content
isola

delphi 12 operator "in" error E2010

Recommended Posts

function TTVInitialsTest.CalcTestVariable({$IF CompilerVersion < 36} VarIndex : integer {$ELSE} VarIndex : NativeInt {$ENDIF}): double;
begin
  Result:=0;
  if InRange(VarIndex, 1, NTestVariables) then
    if (VarIndex in [1 .. TV.Tracks.Count]) and (TV.SimSprocket[VarIndex]<>nil) then
    begin

..................

..................
    end;
end;

Hello everybody.

This code compiles successfully in delphi 11.

In Delphi 12 I have received an error in the line below  ([dcc64 Error]  E2010 Incompatible types: 'Integer' and 'Int64' )

 if (VarIndex in [1 .. TV.Tracks.Count]) and (TV.SimSprocket[VarIndex]<>nil) then

it's obvious that VarIndex and TV.Tracks.Count have the same type - NativeInt (TV.Tracks  is descendant of TList)

I don't understand. Where did I go wrong? Help, please.

Share this post


Link to post
4 hours ago, isola said:

it's obvious that VarIndex and TV.Tracks.Count have the same type - NativeInt (TV.Tracks  is descendant of TList)

Maybe your are wrong. With dcc64 compiler, Integer is 32 bits and NativeInt is 64 bits. Either define varindex as a NativeInt, or use a cast for count (You cannot have more that 2^31 index in that case).

Edited by FPiette

Share this post


Link to post

Thank you, FPiette!

The type of error confused me. Here, apparently the point is that the set size (255) is smaller than the type size (Lenght of the TList object).

The code below contains potential error even in 32-bit code despite it can be compiled.

Something like "Range check error" would have been more informative error message.

VarIndex in [1 .. TV.Tracks.Count]

Thanks again.


 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×