Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8872553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:14:50+00:00 2026-06-14T18:14:50+00:00

Using Delphi XE-2 (all updates applied). I would expect the following code to generate

  • 0

Using Delphi XE-2 (all updates applied).

I would expect the following code to generate compilation errors on the DoSomething and DoInteger calls, but it doesn’t.

program OpenArrayQuestion;

{$APPTYPE CONSOLE}
{$R *.res}

uses
  System.SysUtils;

type
  IComposite = interface(IInterface)
  ['{1AC3CF6A-1316-4838-B67B-9FB075585C1E}']
  end;

  IComposite<T: IComposite> = interface(IComposite)
  ['{7F866990-9973-4F8E-9C1F-EF93EF86E8F2}']
  end;

function DoSomething(const aData: array of IComposite): Boolean;
begin
  Result := True;
end;

function DoInteger(const aData: array of Integer): boolean;
begin
  Result := True;
end;

var
  FData: IComposite;
  FInteger: Integer;
begin
  DoSomething(FData);
  DoInteger(FInteger);
end.

Can somebody explain why I can pass FData/FInteger – both just single variables, to an open array parameter of their respective types without putting it between []‘s and without the compiler barfing it right back at me?

I thought it might have to do with an array of interfaces, or even the generics involved, but the compiler accepts an integer passed to an open array of integer as well.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T18:14:51+00:00Added an answer on June 14, 2026 at 6:14 pm

    The compiler is being a little lax because there is no ambiguity in doing so.

    Consider the following:

    program OpenArrays;
    
    {$APPTYPE CONSOLE}
    
    procedure Test1(i: Integer); overload;
    begin
      Writeln('Test1Integer');
    end;
    
    procedure Test1(i: array of Integer); overload;
    begin
      Writeln('Test1OpenArray');
    end;
    
    procedure Test2(i: array of Integer);
    begin
      Writeln('Test2');
    end;
    
    var
      i: Integer;
    
    begin
      Test1(i);
      Test1([i]);
      Test2(i);
      Readln;
    end.
    

    which produces this output:

    Test1Integer
    Test1OpenArray
    Test2
    

    I’ve overloaded Test1 so that there is a version that receives an integer, and a version that receives an open array of integers. In that situation, the call Test1(i) goes to the overload that receives just an integer. On the other hand, I can call Test2 which receives an open array, just by passing an integer.


    I believe that this behaviour is not documented in the language guide. However, @hvd found the following in the documentation for compiler error E2192 (emphasis mine):

    Open array arguments must be supplied with an actual array variable, a constructed array or a single variable of the argument’s element type.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Delphi 2007 with all patches and updates. I have a file
How can I detect all WiFi networks availables using Delphi? (source: filebuzz.com )
I'm using Delphi IBQuery and IBTransaction components to update all records in database with
The Delphi debugger is great for debugging linear code, where one function calls other
I'm using Delphi 2007 and I wonder how the following problem can be solved:
I'm using Delphi XE and I would like to make a button which shows
Using Delphi 2010 and Indy 10.5.8.0. Against the server Titan FTP I'm getting all
Using Delphi XE 2 I've trying to identify the zoom direction to apply the
Using Delphi 2010 and a patched version of the BDE I run into a
Using Delphi XE2 on Win 7 64 bit creating a 32 bit app... In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.