Every so often the Delphi IDE (from D2 until at least D7) seems to get confused about its line numbers: errors are reported in places there is no code; the debugger jumps about with no apparent relation to the code that is being executed. The Delphi newsgroups propose many diagnoses but, in my experience, the culprit has always been code pasted into the IDE from another source. The Delphi IDE flags line breaks with the characters $D$A but some other editors use $A$D or even just $A or $D. The IDE understands such markers enough to format the code correctly but not enough to mark errors properly. The solution is straightforward but awkward: filter out any improper codes. FirstAid does the job for you.