Delphi Error – E2501 Inline function cannot call nested routine ‘%s’

Delphi Compiler Error

E2501 Inline function cannot call nested routine ‘%s’

Reason for the Error & Solution

This happens when using a nested function inside an inline function.

program E2501;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  UE2501 in 'UE2501.pas';

begin
  {E2501 Inline function cannot call nested routine '%s'}
end.

Unit where the inline function with the nested method is defined:

unit UE2501;

interface
procedure Foo; inline;
implementation
procedure Foo;
    procedure Bar;
    begin
    end;

  begin
    Bar(); //E2501 Fix: change the containing function to a regular function
  end;
end.

Share:

Leave A Reply

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

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...