Recent

Author Topic: Undetected syntax error?  (Read 705 times)

simone

  • Hero Member
  • *****
  • Posts: 626
Undetected syntax error?
« on: October 30, 2024, 05:34:41 pm »
Why does the following code compile without errors (both in ObjFpc and in Delphi modes)?

Note the dot in line #6

Code: Pascal  [Select][+][-]
  1. program Project1;
  2. {$mode ObjFpc}
  3. type
  4.   TShape=(shRectangle, shEllipse, shNone);
  5.   TPointOnBorder=record
  6.     case TShape. of  //note dot!
  7.       shRectangle : (Side : integer;
  8.                      Position : integer);
  9.       shEllipse   : (angle : real);
  10.   end;
  11. begin
  12. end.  
« Last Edit: October 30, 2024, 07:31:47 pm by simone »
Microsoft Windows 10 64 bit - Lazarus 3.0 FPC 3.2.2 x86_64-win64-win32/win64

440bx

  • Hero Member
  • *****
  • Posts: 4740
Re: Undetected syntax error?
« Reply #1 on: October 30, 2024, 06:28:54 pm »
That looks like a bug.  I believe the compiler should require a field/identifier after the ".".

FYI, if you want to draw attention to line #6 (or any other line number), where you have [ code = Pascal ] change that to [ code = Pascal,6 ] (without the spaces), that will highlight line #6.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 16193
  • Censorship about opinions does not belong here.
Re: Undetected syntax error?
« Reply #2 on: October 30, 2024, 07:00:09 pm »
It doesn't even look like a bug. It is a bug.
Delphi7 and Delphi 12.2 do not accept it.
If I smell bad code it usually is bad code and that includes my own code.

simone

  • Hero Member
  • *****
  • Posts: 626
Re: Undetected syntax error?
« Reply #3 on: October 30, 2024, 07:32:31 pm »
FYI, if you want to draw attention to line #6 (or any other line number), where you have [ code = Pascal ] change that to [ code = Pascal,6 ] (without the spaces), that will highlight line #6.

Done! Thnks for hint!
Microsoft Windows 10 64 bit - Lazarus 3.0 FPC 3.2.2 x86_64-win64-win32/win64

440bx

  • Hero Member
  • *****
  • Posts: 4740
Re: Undetected syntax error?
« Reply #4 on: October 30, 2024, 07:33:47 pm »
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Bart

  • Hero Member
  • *****
  • Posts: 5469
    • Bart en Mariska's Webstek
Re: Undetected syntax error?
« Reply #5 on: October 30, 2024, 07:36:26 pm »
Can you test with fpc main, and if it still compiles: file a bugreport.

Bart

Warfley

  • Hero Member
  • *****
  • Posts: 1762
Re: Undetected syntax error?
« Reply #6 on: October 30, 2024, 07:50:04 pm »
The following also works on FPC main:
Code: Pascal  [Select][+][-]
  1.   TShape=(shRectangle, shEllipse, shNone);
  2.   TPointOnBorder=record
  3.     A: TShape.;
  4.   end;

And fixed it: https://gitlab.com/freepascal.org/fpc/source/-/merge_requests/846
« Last Edit: October 30, 2024, 08:03:30 pm by Warfley »

Bart

  • Hero Member
  • *****
  • Posts: 5469
    • Bart en Mariska's Webstek
Re: Undetected syntax error?
« Reply #7 on: October 30, 2024, 07:57:33 pm »
fpc main of today (mine is from september, so a bit old)?

Bart

Thaddy

  • Hero Member
  • *****
  • Posts: 16193
  • Censorship about opinions does not belong here.
Re: Undetected syntax error?
« Reply #8 on: October 30, 2024, 08:16:53 pm »
Bart is right, it is NOT fixed. Main from today. Multiple platforms.
( I also see multiple pipe line failures: for sane people like you, that means the patch doesn't pass automatic tests)
« Last Edit: October 30, 2024, 08:23:11 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

Warfley

  • Hero Member
  • *****
  • Posts: 1762
Re: Undetected syntax error?
« Reply #9 on: October 30, 2024, 08:24:37 pm »
Because I just made the merge request, until it's accepted it will not be on main :)

And if you are referring to the 16 test failures, they are always there. None of them were introduced by my fix. There are just a few things on main that do fail all the time (it's an unstable development branch after all).

Thaddy

  • Hero Member
  • *****
  • Posts: 16193
  • Censorship about opinions does not belong here.
Re: Undetected syntax error?
« Reply #10 on: October 30, 2024, 08:25:07 pm »
fpc main of today (mine is from september, so a bit old)?

Bart
Shame on you,Bart.. :-X
If I smell bad code it usually is bad code and that includes my own code.

Thaddy

  • Hero Member
  • *****
  • Posts: 16193
  • Censorship about opinions does not belong here.
Re: Undetected syntax error?
« Reply #11 on: October 30, 2024, 08:28:39 pm »
Because I just made the merge request, until it's accepted it will not be on main :)

And if you are referring to the 16 test failures, they are always there. None of them were introduced by my fix. There are just a few things on main that do fail all the time (it's an unstable development branch after all).
I don't mean to critise you, I know you contribute a lot.
The observation is just that it is not commited...maybe yet.
You were not clear about that.

regards,
Thaddy
« Last Edit: October 30, 2024, 08:30:12 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

 

TinyPortal © 2005-2018