Delphi Error – E2138 Invalid message parameter list

Delphi Compiler Error

E2138 Invalid message parameter list

Reason for the Error & Solution

A message procedure can take only one, VAR, parameter; it’s type is not checked.

program Produce;

  type
    Base = class
      procedure Msg1(x : Integer); message 151;
      procedure Msg2(VAR x, y : Integer); message 152;
    end;

  procedure Base.Msg1(x : Integer);
  begin
  end;

  procedure Base.Msg2(VAR x, y : Integer);
  begin
  end;

begin
end.

The obvious error in the first case is that the parameter is not VAR. The error in the second case is that more than one parameter is declared.

program Solve;

  type
    Base = class
      procedure Msg1(VAR x : Integer); message 151;
      procedure Msg2(VAR y : Integer); message 152;
    end;

  procedure Base.Msg1(VAR x : Integer);
  begin
  end;

  procedure Base.Msg2(VAR y : Integer);
  begin
  end;

begin
end.

The solution in both cases was to only specify one, VAR, parameter in the message method declaration.

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error E2313 Attribute – Known attribute cannot specify properties Reason for the Error & Solution No further information...
Delphi Compiler Error E2379 Virtual methods not allowed in record types Reason for the Error & Solution No further information...
Rodrigo , one of the long time Delphi Developer has been working on one of his personal project “Delphi IDE...