Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2010-11

very misleading error msg...

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin

(using the -Se 10 switch)

Compiling C:\Users\martin\AppData\Local\Temp\syn\project1.lpr
project1.lpr(9,5) Error: Illegal expression
project1.lpr(9,5) Fatal: Syntax error, "EXCEPT" expected but "identifier
WRITELN" found

The illegal expression is ok.
But why saying that "Except" was expected? Imho that is misleading, since the source can continue with anything else here

Is that something that would be worth a report in mantis, in order to improve error msgs?

program Project1;
{$mode objfpc}{$H+}
var a: Integer;
begin
   try
     writeln();
     a
     writeln();
   finally
   end;
end.

Reply by email

Sven Barth
to Martin
Martin wrote
The illegal expression is ok. But why saying that "Except" was expected? Imho that is misleading, since the source can continue with anything else here

I can only assume the following:

Before an "except" or a "finally" the ";" is optional (like in every(?) block). Thus after a statement without a ";" either a "finally" or an "except" is expected and the compiler simply assumes that it's in a "try...except" block first. Or it's just because "except" is declared before "finally" in the token array which is kept ordered by token length first and lexicographically second.

Regards,
Sven

Reply by email

Martin
to Sven Barth
Sven Barth wrote 13 lines
On 13.11.2010 14:59, Martin wrote: > The illegal expression is ok. > But why saying that "Except" was expected? Imho that is misleading, > since the source can continue with anything else here I can only assume the following: Before an "except" or a "finally" the ";" is optional (like in every(?) block). Thus after a statement without a ";" either a "finally" or an "except" is expected and the compiler simply assumes that it's in a "try...except" block first. Or it's just because "except" is declared before "finally" in the token array which is kept ordered by token length first and lexicographically second.

Ah that makes sense (the semicolon part).

indeed I was not bothered if it is except or finally...

Thanks

Reply by email