[fpc-devel] Implicit function specialization precedence

Sven Barth pascaldragon at googlemail.com
Sat Apr 10 14:54:29 CEST 2021


Am 10.04.2021 um 10:38 schrieb Sven Barth:
> Am 10.04.2021 um 00:43 schrieb Ryan Joseph via fpc-devel:
>>
>>> On Apr 9, 2021, at 4:31 PM, Sven Barth via fpc-devel 
>>> <fpc-devel at lists.freepascal.org> wrote:
>>>
>>> You mean what you did for is_array_literal? A pure array constructor 
>>> can be found with is_array_constructor, though it might be better to 
>>> use is_open_array, cause someone might pass an open array parameter 
>>> to a generic function (those will be unnamed as well).
>> Maybe the email didn't go through? How to identify this "array of 
>> const constructor" type. I want to reject these for implicit 
>> specialization but I can't identity them.
>>
>>   DoThis([
>>     1,
>>     'string',
>>     'c',
>>     TObject.Create
>>   ])
>
> You can't really differentiate these from array constructors with just 
> one type, because the type is only really determined once the overload 
> is chosen as that kind of array could be an array of const, an array 
> of Variant or maybe even an array of LongInt if there are suitable 
> operator overloads in scope. So, yeah, it's kinda hard to decide what 
> type to use...

*Now* your other mail arrived. ;)

As an additional note: if you take a look at 
tarrayconstructornode.pass_typecheck you can see that the array type 
always has the ado_IsConstructor set and if it contains of incompatible 
types the ado_IsVariant is set as well. So if ado_IsVariant is *not* 
set, then you can rely on the elementdef of the arraydef.

Regards,
Sven


More information about the fpc-devel mailing list