View Issue Details

IDProjectCategoryView StatusLast Update
0036631FPCCompilerpublic2020-02-11 23:01
ReporterNoNameAssigned ToSven Barth 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.3.1Product Build 
Target VersionFixed in Version3.2.0 
Summary0036631: Mode Delphi allows .[index] for TArray while Delphi doesn't
DescriptionThe following code compiles and works fine in FPC 3.2 but in Delphi it gives:
Error: E2018 Record, object or class type required

SingleStr := LongStr.Split([','.')']).[1];
TagsNo tags attached.
Fixed in Revision44082
FPCOldBugId
FPCTarget3.2.0
Attached Files

Activities

Jonas Maebe

2020-01-26 17:07

manager   ~0120764

Please always provide a compilable program when reporting bugs.

NoName

2020-01-26 17:08

reporter   ~0120765

Example code should be: SingleStr := LongStr.Split([',', '.']).[1];

Jonas Maebe

2020-01-26 17:11

manager   ~0120766

That is not a compilable program. You are missing at least a uses clause, variable declarations, and "begin .. end."

NoName

2020-01-26 17:12

reporter   ~0120767

program x;

{$APPTYPE CONSOLE}

uses
  Classes,
  SysUtils;

var
  LongStr: String;
  SingleStr: String;

begin
  LongStr := 'Some example, test text. Another one, or something like that.';

  SingleStr := LongStr.Split([',', '.']).[1];
  writeln(SingleStr); // ' test text'

  writeln('done');
end.

NoName

2020-01-26 17:13

reporter   ~0120768

Didn't read your message, just noticed the wrong code in the bug report.
But there you've an example.

Thaddy de Koning

2020-01-26 19:17

reporter   ~0120770

This is perfectly fine. There are more FPC features in Delphi mode that Delphi does not support.
Mode Delphi just guarantees some level (e.g. D7, 2006,2009) of compatibility with Delphi originated code, but not the other way around.
That is a misunderstanding that often occurs. There must be many duplicates.

Sven Barth

2020-01-27 14:56

manager   ~0120777

No, this is not fine. ".[...]" is not a valid syntax. If the "[...]" stems from a built in array accessor or a default property in a type helper it should be *only* "[...]", not ".[...]".

Thaddy de Koning

2020-01-27 17:22

reporter   ~0120779

I interpreted that as a typo.

Sven Barth

2020-02-01 18:53

manager   ~0120840

Please test and close if okay.

NoName

2020-02-09 16:42

reporter   ~0120972

Maybe also backport to FPC 3.2?

Issue History

Date Modified Username Field Change
2020-01-26 17:03 NoName New Issue
2020-01-26 17:07 Jonas Maebe Status new => feedback
2020-01-26 17:07 Jonas Maebe FPCTarget => -
2020-01-26 17:07 Jonas Maebe Note Added: 0120764
2020-01-26 17:08 NoName Note Added: 0120765
2020-01-26 17:08 NoName Status feedback => new
2020-01-26 17:11 Jonas Maebe Status new => feedback
2020-01-26 17:11 Jonas Maebe Note Added: 0120766
2020-01-26 17:12 NoName Note Added: 0120767
2020-01-26 17:12 NoName Status feedback => new
2020-01-26 17:13 NoName Note Added: 0120768
2020-01-26 19:17 Thaddy de Koning Note Added: 0120770
2020-01-27 14:56 Sven Barth Note Added: 0120777
2020-01-27 17:22 Thaddy de Koning Note Added: 0120779
2020-02-01 16:59 Sven Barth Assigned To => Sven Barth
2020-02-01 16:59 Sven Barth Status new => assigned
2020-02-01 18:53 Sven Barth Status assigned => resolved
2020-02-01 18:53 Sven Barth Resolution open => fixed
2020-02-01 18:53 Sven Barth Fixed in Version => 3.3.1
2020-02-01 18:53 Sven Barth Fixed in Revision => 44082
2020-02-01 18:53 Sven Barth Note Added: 0120840
2020-02-09 16:42 NoName Status resolved => closed
2020-02-09 16:42 NoName Note Added: 0120972
2020-02-11 23:01 Sven Barth Fixed in Version 3.3.1 => 3.2.0
2020-02-11 23:01 Sven Barth FPCTarget - => 3.2.0