This is just an educated guess as the provided code is sparse. The small hints the provided code gave:
uses
provided in the code sample after the declaration contain
System.SysUtils
, the unit where TBytes
is defined
- The provided uses are after the declaration, so
TBytes
there must
have a different source than System.SysUtils
Therefore it is likely that TBytes
is not actually referring to the same type in declaration and implementation part. This can be visualized for example by hovering the mouse over a type. The tool tip will tell you what the exact type is the compiler is referring to.
I can for example reproduce your problem with two small units. TBytes
is declared in System.SysUtils
, but I declare another one - like it is defined in Delphi 2009 (see below) in Unit3
:
unit Unit3;
interface
type
TBytes = array of Byte;
implementation
end.
When I now create a unit like the following, I'm mixing up the usage of TBytes from two different Units, that aren't compatible:
unit Unit2;
interface
uses
Unit3;
function ReadBytes(maxLen: integer): TBytes;
implementation
uses
System.SysUtils;
function ReadBytes(maxLen: integer): TBytes;
begin
//
end;
end.
The types that the tool tip will show are type Unit3.TBytes: array of Byte
and type System.SysUtils.TBytes: System.Array<System.Byte>
.
So in fact the signature of my function in the declaration differs from the signature in the implementation.
This can be resolved by
- Inspecting if the used units are actually correct and needed, can you
get rid of the one causing ambiguity?
If not possible to solve it with the first point, it is possible
to refer explicitly to which type is meant by prefixing with the
containing unit:
function ReadBytes(maxLen: integer): Unit3.TBytes;
I looked at the history of System.SysUtils.TBytes
retroactively, couldn't find it for Delphi 7, but in Delphi 2009 the definition of TBytes was following: TBytes = array of Byte;
I have changed my code example with that in mind and rephrased part of the answer.