I did not know that when a procedure / function expects an open array parameter, it is possible to invoke it with a scalar value of the same type as the array. In other words, this is possible:
program project1;
var
S : string;
procedure Proc(L : array of string);
begin
writeln(Length(L));
readln;
end;
begin
Proc(S);
end.
Just for the sake of knowledge: is this behavior explicitly contemplated in the language specification?
While not documented as such, yes, this is explicitly supported. So please file a bug for the documentation of open array parameters that this is missing.
Side note: this functionality works with essentially no effort, because an open array parameter is internally a pointer to the first element of the array plus an additional parameter with the
High value. A single element then is simply a pointer to that element and the
High parameter has a value of
1. This also explains the error in Delphi that (untyped) constants can't be used: one can't get a pointer to them.