The thing is, the function is not a method, and is not nested. It's just a plain vanilla function.
...
There must be something in the code that is confusing FPC. It will be interesting to find out what it is.
Kind of hard to judge that when you did not show the full code.
I know but, the unit is almost 6000 lines and in the middle of being edited for porting.
I should have probably mentioned that I figured out what the problem was. Kind of hard to explain how thing that got there but, in the midst of conditional directives and definitions, there was an unmatched brace. It didn't bother Delphi but, it somehow ended up creating a partial definition for a function and FPC saw the whole remainder of the program as being part of the function.
What helped me figure it out is that, once I had eliminated all the other syntactic details FPC didn't like and, it got to the end of the unit, it complained that it expected a semicolon and not a period after the "end" (the "end." that marked the unit's end).
The compiler was telling the truth, it was seeing a whole slew of functions and procedures inside another one and complained that the function was not properly terminated (with an "end;".)
Remy, thank you for trying to help, I appreciate it.