Recent

Author Topic: Internal Error with Generic Nested Routines  (Read 2681 times)

simone

  • Sr. Member
  • ****
  • Posts: 394
Internal Error with Generic Nested Routines
« on: June 05, 2021, 09:34:40 pm »
As is known, starting from version 3.2.0 FPC supports generic free-standing (i.e. standing out of a type declaration) procedures / functions. Since this new feature is documented only here: https://wiki.freepascal.org/FPC_New_Features_3.2.0#Support_for_Generic_Routines, no mention in the language reference guide, I did some experiments to better understand benefits and limitations.

I found that the following program in FPC 3.2.0 generates an internal error (always, not randomly):

Code: Pascal  [Select][+][-]
  1. program Project1;
  2. {$mode ObjFPC}
  3.  
  4. procedure AddGroup;
  5.  
  6.   generic procedure Add<T>(const X : T; const Y : T; out Z : T);
  7.   begin
  8.     Z:=X+Y;
  9.   end;
  10.  
  11.   var
  12.     R : integer;
  13.  
  14.   begin
  15.     specialize Add<integer>(4,5,R);
  16.   end;
  17.  
  18. begin
  19.    AddGroup;
  20. end.

Compiler Output:

C:\Users\simon\AppData\Local\Temp\project1.lpr(16,6) Fatal: Internal error 200511152

I don't know if generic nested procedures / functions are supported. If not, I would still expect a syntax error, not an internal error. What do you think?
« Last Edit: June 05, 2021, 09:41:00 pm by simone »
Microsoft Windows 10 64 bit - Lazarus 2.0.12

Bart

  • Hero Member
  • *****
  • Posts: 4358
    • Bart en Mariska's Webstek
Re: Internal Error with Generic Nested Routines
« Reply #1 on: June 05, 2021, 09:53:23 pm »
Same with fpc trunk r49116.

Maybe file a bugreport (and attach the sample project).
I could not find an existing bugreport about IE 200511152 in the bugtracker.

Bart

simone

  • Sr. Member
  • ****
  • Posts: 394
Re: Internal Error with Generic Nested Routines
« Reply #2 on: June 05, 2021, 10:02:48 pm »
Thanks Bart for confirming. I have opened a bug report.
Microsoft Windows 10 64 bit - Lazarus 2.0.12

PascalDragon

  • Hero Member
  • *****
  • Posts: 3204
  • Compiler Developer
Re: Internal Error with Generic Nested Routines
« Reply #3 on: June 06, 2021, 01:08:05 pm »
I don't know if generic nested procedures / functions are supported. If not, I would still expect a syntax error, not an internal error. What do you think?

I mostly tested global routines and methods when I developed them, so better stick to those till the bug you reported is fixed. And you might also want to file a bug regarding the missing documentation of them in the language reference guide.

simone

  • Sr. Member
  • ****
  • Posts: 394
Re: Internal Error with Generic Nested Routines
« Reply #4 on: June 06, 2021, 08:33:48 pm »
Already done in the past: https://bugs.freepascal.org/view.php?id=37256, but this feature is not yet documented in the language reference guide.
Microsoft Windows 10 64 bit - Lazarus 2.0.12

PascalDragon

  • Hero Member
  • *****
  • Posts: 3204
  • Compiler Developer
Re: Internal Error with Generic Nested Routines
« Reply #5 on: June 07, 2021, 09:00:43 am »
Already done in the past: https://bugs.freepascal.org/view.php?id=37256, but this feature is not yet documented in the language reference guide.

You should have reopened the bug or made a new one. Commenting on resolved bugs gets easily lost in the noise.

simone

  • Sr. Member
  • ****
  • Posts: 394
Re: Internal Error with Generic Nested Routines
« Reply #6 on: June 07, 2021, 10:26:06 am »
I took your advice. I hadn't opened a new bug report to not create duplicates.
Microsoft Windows 10 64 bit - Lazarus 2.0.12

 

TinyPortal © 2005-2018