[fpc-pascal] "Unexpected end of file" when having an open comment after the final "end."

Thomas Kurz fpc.2021 at t-net.ruhr
Thu Feb 8 13:30:42 CET 2024


Hello all,

I'm unsure about whether or not to report this as a bug. Imho, it is a bug, but maybe there's a good reason to handle this.

Please take the following example:

---start---

program test;

begin
end.

{

---end---

Result:

Z:\>ppc386.exe testproj.pas
Free Pascal Compiler version 3.2.2 [2022/05/15] for i386
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling testproj.pas
testproj.pas(6,1) Fatal: Unexpected end of file
Fatal: Compilation aborted


I'd say the code should compile without any errors for the following reasons:

1. The "end." tells the compiler that the file is finished here. Whatever comes after this should not be considered by the compiler.
2. The compiler doesn't consider any other statement after "end.". For example, replacing the open comment with something like "vra" doesn't cause an error either.

Kind regards,
Thomas



More information about the fpc-pascal mailing list