[fpc-devel] C-block reference syntax (blocker for 3.2)x

Michael Van Canneyt michael at freepascal.org
Thu Dec 12 17:19:03 CET 2019



On Thu, 12 Dec 2019, Michael Van Canneyt wrote:

>
>
> On Thu, 12 Dec 2019, Sven Barth via fpc-devel wrote:
>
>> Michael Van Canneyt <michael at freepascal.org> schrieb am Do., 12. Dez. 2019,
>> 15:34:
>>
>>>> It was already mentioned, that the [] can be dropped if the array has
>>>> *exactly one* element.
>>>
>>> Not sure what you mean here, but even if there is only 1 argument, today
>>> the [] cannot be dropped:
>>>
>>> home:~> cat tf.pp
>>> program tf;
>>>
>>> uses sysutils;
>>>
>>> begin
>>>    writeln(Format('%s','huh?'));
>>> end.
>>> home:~> fpc tf.pp
>>> tf.pp(6,29) Error: Incompatible type for arg no. 2: Got "Constant String",
>>> expected "Array Of Const"
>>> tf.pp(8) Fatal: There were 1 errors compiling module, stopping
>>> Fatal: Compilation aborted
>>> Error: /usr/local/bin/ppcx64 returned an error exitcode
>>>
>>
>> For array of const it is not allowed, but any other open array parameter
>> allows it.
>
> Really, are you sure ? Since when is this allowed ?
>
> Today's compiler:
>
> araminta: ~ >fpc -S2 ti.pp
> ti.pp(8,6) Error: Incompatible type for arg no. 1: Got "ShortInt", expected 
> "{Open} Array Of LongInt"
> ti.pp(9,4) Fatal: There were 1 errors compiling module, stopping
> Fatal: Compilation aborted
> Error: /usr/local/bin/ppcx64 returned an error exitcode
> araminta: ~ >cat ti.pp
>
> procedure a(b : array of integer);
>
> begin
> end;
>
> begin
>   A(1);
> end.
>
> Tested with 3.0.4 and trunk.

Delphi prints:
[dcc32 Error] ti.dpr(13): E2192 Constants cannot be used as open array arguments

Michael.


More information about the fpc-devel mailing list