adem0x / la-pe

Automatically exported from code.google.com/p/la-pe
0 stars 0 forks source link

Ambiguous call with [] as TBox #31

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
procedure Test(box: TBox);
begin
  writeln(box);
end;

begin
  Test([1, 2, 3, 4]);
end.

This works fine but adding any overloaded method would result in ambiguous 
call. Since the argument [1, 2, 3, 4] could only be either a TBox or 
TIntegerArray, adding an overloaded method with parameter not being 
TIntegerArray should work fine?

Original issue reported on code.google.com by riwu0...@gmail.com on 10 Apr 2014 at 12:44

GoogleCodeExporter commented 9 years ago
Currently, this is not a problem. Yes, the call is ambiguous, but the compiler 
will pick the method with IntegerArray as parameter. This is expected behavior 
because of of backwards compatibility with Pascal. If you want to call the 
method with the TBox parameter, you would have to explicitly cast to TBox.

Original comment by niels....@gmail.com on 12 Aug 2014 at 12:40