This error message is displayed when one of the identifiers in the Dispose parameter list is not a destructor.
program Produce; type PMyObject = ^TMyObject; TMyObject = object F: Integer; constructor Init; destructor Done; end; constructor TMyObject.Init; begin F := 42; end; destructor TMyObject.Done; begin end; var P: PMyObject; begin New(P, Init); (*...*) Dispose(P, Init); (*<-- Error message here*) end.
The constructor was accidentally passed to Dispose in this example.
program Solve; type PMyObject = ^TMyObject; TMyObject = object F: Integer; constructor Init; destructor Done; end; constructor TMyObject.Init; begin F := 42; end; destructor TMyObject.Done; begin end; var P: PMyObject; begin New(P, Init); Dispose(P, Done); end.
Either supply a destructor to Dispose or remove the second argument as a solution.
Leave a Reply