View Issue Details

IDProjectCategoryView StatusLast Update
0035824FPCCompilerpublic2019-07-10 22:46
ReporterAkira1364Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Platformx86_64OSWindowsOS Version10
Product Version3.3.1Product BuildTrunk 
Target VersionFixed in Version 
Summary0035824: [Feature Request] Extend "for Variable in [Value, Value, Value]" to imply an array when a set would be impossible.
DescriptionFPC has recently seen some very nice extensions to the syntax surroundings arrays, e.g. being able to do things like:

ArrayVariable := [Value, Value, Value];

However, it still remains that case that when you write:

for Variable in [Value, Value, Value] do Whatever;

"[Value, Value, Value]" is never interpreted as anything other than a set, which restricts it to byte-sized types.

For example:

program SetLoop;

var I: LongInt;

begin
  // Works fine.
  for I in [2, 12, 16, 17, 255] do WriteLn(I);
  // Range check error, as this syntax *always* implies a set,
  // and sets are restricted to byte-sized types in all cases.
  for I in [2, 12, 16, 17, 259] do WriteLn(I);
end.

If feasible, it would be nice if in any case where a set could not validly represent the given values, that this would essentially amount to an "anonymous array".

This could mean making it basically syntactic sugar for:

"for Variable in ArrayOfType.Create(Value, Value Value)"

or (preferably I suppose) by making it amount instead to a static array constant (since the length is known) if / where possible.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2019-07-10 22:26 Akira1364 New Issue