Delphi Compiler Error
E2122 PROCEDURE or FUNCTION expected
Reason for the Error & Solution
This error message is produced by two different constructs, but in both cases the compiler is expecting to find the keyword ‘procedure’ or the keyword ‘function’.
program Produce; type Base = class class AProcedure; (*case 1*) end; class Base.AProcedure; (*case 2*) begin end; begin end.
In both cases above, the word ‘procedure’ should follow the keyword ‘class’.
program Solve; type Base = class class procedure AProcedure; end; class procedure Base.AProcedure; begin end; begin end.
As can be seen, adding the keyword ‘procedure’ removes the error from this program.