HomeDelphiDelphi Error – E2138 Invalid message parameter list

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

You May Also Like

Delphi Compiler Error X2421 Imported identifier ‘%s’ conflicts with ‘%s’ in ‘%s’ Reason for the Error & Solution This occurs...
Delphi Compiler Error X2367 Case of property accessor method %s.%s should be %s.%s Reason for the Error & Solution No...
Delphi Compiler Error X2269 Overriding virtual method ‘%s.%s’ has lower visibility (%s) than base class ‘%s’ (%s) Reason for the...