Sign in Join

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

Mailing lists / fpc-pascal / 2016-08

Doubt related to the issue #30498

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

silvioprog

Hello,

A possible inline way (without declaring specialized local variables) to compile the attached test at the issue #30498
<http://bugs.freepascal.org/view.php?id=30498> is:

...
  procedure Test(const AItems: TArray<string>);
  begin
  end;
begin
  // Test(['foo', 'bar']); issue #30498
  Test(TArray<string>.Create('foo', 'bar'));
...

However, how to do something like this in the following declaration?:

...
procedure Test(const AItems: TArray<TPair<string, string>>); ...

I've tried:

...
  procedure Test(const AItems: TArray<TPair<string, string>>);
  begin
  end;
begin
  Test(TArray<TPair<string, string>>.Create(TPair<string,
string>.Create('foo', 'bar')));
...

Got:

project1.dpr(18,37) Error: Illegal expression
project1.dpr(18,38) Fatal: Syntax error, ")" expected but "identifier
CREATE" found

Thank you!

Silvio Clécio

Reply by email

Sven Barth
"silvioprog" wrote
Hello, A possible inline way (without declaring specialized local variables) to

compile the attached test at the issue #30498 is:

Show quoted text 26 lines
... procedure Test(const AItems: TArray<string>); begin end; begin // Test(['foo', 'bar']); issue #30498 Test(TArray<string>.Create('foo', 'bar')); ... However, how to do something like this in the following declaration?: ... procedure Test(const AItems: TArray<TPair<string, string>>); ... I've tried: ... procedure Test(const AItems: TArray<TPair<string, string>>); begin end; begin Test(TArray<TPair<string, string>>.Create(TPair<string,
string>.Create('foo', 'bar')));
Show quoted text 6 lines
... Got: project1.dpr(18,37) Error: Illegal expression project1.dpr(18,38) Fatal: Syntax error, ")" expected but "identifier

CREATE" found

See here: http://bugs.freepascal.org/view.php?id=30503

Regards,
Sven

Reply by email

silvioprog
to Sven Barth

On Tue, Aug 23, 2016 at 2:57 AM, Sven Barth
wrote:
[...]

Show quoted text 5 lines

Thank you! :-)

I did:

...
{$IFDEF FPC}
var
  VPairs: TArray<TPair<TClass, string>>;
{$ENDIF}
begin
...
{$IFDEF FPC}
  // issues #30503 and #30498
  SetLength(VPairs, 2);
  VPairs[0] := TPair<TClass, string>.Create(TMyObject, 'my qualifier');
  VPairs[1] := TPair<TClass, string>.Create(TMySerializable,
TMySerializable.QualifiedClassName);
  TClassRegistry.Register(VPairs);
{$ELSE}
  TClassRegistry.Register([TPair<TClass, string>.Create(TMyObject, 'my
qualifier'),
    TPair<TClass, string>.Create(TMySerializable, TMySerializable.
QualifiedClassName)]);
{$ENDIF}
...

and now my test-case compiles fine.

Silvio Clécio

Reply by email