rtl-objpas / rtti.pp => RTttiMethod.toString : inconsistent appearance of parameter name

Original Reporter info from Mantis: Martin @martin_frb
  • Reporter name: Martin Friebe

Description:

Fpc 3.2.2 // Fpc trunk from about March 2021

The below program prints

const a: Byte
b: Word
c: Word
var a: TEnum1
array of Int64

The parameter name is always included, except for the open array param.

I would expect it to be always included

Steps to reproduce:

program Project1;
{$mode objfpc}{$H+}
uses
  Classes, TypInfo, Rtti;

type
  TEnum1 = (a,b,c);
  t1 = function (const a: byte; b,c: word): boolean;
  t2 = procedure (var a: TEnum1; b: array of Int64) of object;
var
  context: TRttiContext;
  params: specialize TArray<TRttiParameter>;
  t: TRttiType;
  i: Integer;
begin
  context := TRttiContext.Create;
  t := context.GetType(PTypeInfo(TypeInfo(t1)));
  params := TRttiInvokableType(t).GetParameters;
  for i := 0 to Length(params) - 1 do
    writeln(params[i].tostring);

  t := context.GetType(PTypeInfo(TypeInfo(t2)));
  params := TRttiInvokableType(t).GetParameters;
  for i := 0 to Length(params) - 1 do
    writeln(params[i].tostring);

  context.Free;
  ReadLn;
end.

Mantis conversion info:

  • Mantis ID: 38934
  • OS: win 10
  • OS Build: 10
  • Platform: 64bit Intel
  • Version: 3.2.2