I have a DUnitX test suite that works fine on Win32. But when I try to compile it for Win64, this line generates a compilation error:
Assert.AreEqual(4, Length(r.Values));
[dcc64 Error] ...: E2532 Failed to derive a generic type argument from different argument types for the 'AreEqual' method
r.Values is defined as:
Type TIntegers = TArray<Integer>
Assert.AreEqual has different overloaded implementations, and dcc64 cannot choose the right one ... ok, but why? And why can dcc32 compile this without a problem?
The only key I have is that if I hover over it, Delphi will tell me that Length is of type System.Smallint. There is no implementation of Assert.AreEqual with Smallint parameters ... and, of course, if I pass it Integer, dcc64 will compile it.
But that really bothers me. If I look into the System.pas block, I see that DynArraySetLength accepts the NativeInt parameter ... a 64-bit integer (I would expect an unsigned one, but not sure about that). So why should Length return a signed 16-bit integer? It would seem that trouble awaits, right?
What am I missing?
source
share