View Issue Details

IDProjectCategoryView StatusLast Update
0037272FPCCompilerpublic2020-06-28 00:34
Reporterdmz73 Assigned ToSven Barth  
Status resolvedResolutionfixed 
Product Version3.2.0 
Fixed in Version3.3.1 
Summary0037272: Compiler uses [] as empty set instead of empty array in default procedure parameter declaration
DescriptionWhen declaring a procedure with dynamic array parameter and specifying empty array as the default value, compiler reports Error: Incompatible types: got "Empty Set" expected "<array type>".
If empty array is used in procedure call the error is not reported.
Steps To ReproduceCompile the example project below:

program Project1;

  TA1 = array of integer;

procedure Test(A: integer; const B: TA1 = []);
begin end;

  Test(1, []);
TagsNo tags attached.
Fixed in Revision45706
Attached Files


jamie philbrook

2020-06-27 02:53

reporter   ~0123608

I don't know if that is really a bug or not ?

but …

Procedure Test(A :Integer; Const B:TA1 = Nil); // empy array …

 Later on, you simply pass it a valid TA1 object...
 So basically its a variable array except it's created prior to instead of during the procedure call.

  Test(1. T);
 and it passes a Nil array

Jonas Maebe

2020-06-27 16:11

manager   ~0123621

As mentions, only simple types are supported as default values. An array is not a simple type, but as set is. Additionally, because of the supported conversion of nil to dynamic array (and nil being a pointer, i.e., a simple type), you can indeed use nil as well for dynamic arrays.

Sven Barth

2020-06-27 20:25

manager   ~0123631

Last edited: 2020-06-27 20:25

View 2 revisions

@Jonas: Delphi compiles this as well and I already have the fix ready (what is not allowed are non-empty arrays).

Sven Barth

2020-06-28 00:34

manager   ~0123641

Please test and close if okay.

Issue History

Date Modified Username Field Change
2020-06-27 01:46 dmz73 New Issue
2020-06-27 02:53 jamie philbrook Note Added: 0123608
2020-06-27 16:11 Jonas Maebe Assigned To => Jonas Maebe
2020-06-27 16:11 Jonas Maebe Status new => resolved
2020-06-27 16:11 Jonas Maebe Resolution open => no change required
2020-06-27 16:11 Jonas Maebe FPCTarget => -
2020-06-27 16:11 Jonas Maebe Note Added: 0123621
2020-06-27 20:25 Sven Barth Assigned To Jonas Maebe => Sven Barth
2020-06-27 20:25 Sven Barth Status resolved => feedback
2020-06-27 20:25 Sven Barth Resolution no change required => reopened
2020-06-27 20:25 Sven Barth Note Added: 0123631
2020-06-27 20:25 Sven Barth Note Edited: 0123631 View Revisions
2020-06-27 21:03 Sven Barth Status feedback => assigned
2020-06-28 00:34 Sven Barth Status assigned => resolved
2020-06-28 00:34 Sven Barth Resolution reopened => fixed
2020-06-28 00:34 Sven Barth Fixed in Revision => 45706
2020-06-28 00:34 Sven Barth Note Added: 0123641
2020-06-28 00:34 Sven Barth Fixed in Version => 3.3.1