HomeDelphiDelphi Error – E2031 Label expected

Delphi Error – E2031 Label expected

Delphi Compiler Error

E2031 Label expected

Reason for the Error & Solution

This error message occurs if the identifier given in a goto statement or used as a label in inline assembly is not declared as a label.

program Produce;

begin
  if 2*2 <> 4 then
    goto Exit; (*<-- Error message here: Exit is also a standard procedure*)
  (*...*)
Exit:              (*Additional error messages here*)
end.
	program Solve;
label
  Exit;            (*Labels must be declared in Delphi*)
begin
  if 2*2 <> 4 then
    goto Exit;
  (*...*)
Exit:
end.

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