Ad Space — Top Banner

E2037

Delphi Programming Language

Severity: Moderate

What Does This Error Mean?

E2037 means you declared a method or function earlier (usually in the interface section or class declaration) and then wrote the implementation with a different signature. The parameter names, types, return type, or calling convention must match exactly between the declaration and the implementation. Fix it by making the implementation signature identical to the declaration.

Affected Models

  • Delphi 10.4 Sydney
  • Delphi 11 Alexandria
  • Delphi 12 Athens
  • Embarcadero RAD Studio
  • Free Pascal / Lazarus

Common Causes

  • Adding or removing a parameter in the implementation that was not in the class declaration
  • Changing a parameter type in the implementation (e.g., Integer to Int64)
  • Changing a var or const parameter modifier in the implementation
  • Changing the return type of a function in the implementation
  • Mismatching the calling convention (cdecl, stdcall) between declaration and implementation

How to Fix It

  1. Open the class declaration (usually in the interface section or .pas header) and locate the method signature the error refers to.

    The error message names the method — search for it in the interface section.

  2. Compare the declaration signature to the implementation signature, character by character: parameter names, types, modifiers (var, const, out), and the return type.

    Even changing a parameter name between declaration and implementation can cause E2037 in some Delphi versions.

  3. Make the implementation header an exact copy of the declaration, then add the class name prefix: procedure TMyClass.DoSomething(Value: Integer);

    Copy the parameter list from the declaration rather than retyping it to avoid typos.

  4. Check calling conventions — if the declaration says stdcall, the implementation must also say stdcall.

    Calling convention mismatches are easy to miss because the convention is usually written at the end of the signature.

  5. If the method was recently changed in the class declaration, update the implementation to match the new signature.

    Use the Delphi IDE's Ctrl+Shift+Up/Down shortcut to jump between declaration and implementation quickly.

When to Call a Professional

This is a compiler error — no professional repair needed. Fix it by reading the error message and correcting the code. The Delphi IDE highlights the exact line causing the problem.

Frequently Asked Questions

What is a forward declaration in Delphi?

A forward declaration is when you write the method signature in the class declaration or interface section without providing the body yet. The body (implementation) is written later in the implementation section. Delphi requires the two signatures to match exactly so it can link the declaration to the correct implementation.

Does the parameter name need to match between declaration and implementation?

In most cases Delphi only checks the types and modifiers, not the parameter names. However, some versions and some contexts (especially with published properties or RTTI) do check names. It is best practice to keep the parameter names identical to avoid confusion and potential issues.

Can E2037 occur with overloaded methods?

Yes — if you have multiple overloaded versions of a method and one of their implementations does not match any of the declarations, you will get E2037. Make sure each implementation exactly matches one of the overloaded declarations, including the overload directive.