Getting "Delegates cannot use Extends, Assigns, or ParamArray", is this a bug?

I just upgraded from 2025 1.1 to 2025 2.1 and now getting an error at compile time stating “Delegates cannot use Extends, Assigns, or ParamArray”

In the documentation, this error is under the “Xojoscript” topic, but cannot find it elsewhere.

Also noticed that “On Android, you cannot use ParamArray with a Delegate.”

I’m running Xojo on Mac targeting ‘this computer’ and Architecture is set to ARM-64. Same error message targeting x86 .
Cannot find mention this feature is deprecated.

Prototype of the offending function:

Delegate FilterColumnByRows(pRowIndex as integer, pRowCount as integer, pColumnName as string, the_cell_value as variant, paramarray pFunctionParameters as variant)

Is this an expected change ?

Serge

While waiting for an answer, what happens if you change the last parameter to pFunctionParameters() As Variant (just an array, not a ParamArray).

1 Like

Compilation works.

And test are ok.

Two functions were flagged with error. FilterColumnByRows (mentioned above) and (after updating as per suggestion):

Delegate Function RowFilter(pRowIndex as integer, pRowCount as integer, pColumnNames() as string, pCellValues() as variant, pFunctionParameters() as variant) as boolean

The latest delegate is referenced in the following function prototype:

function ApplyFilterFunction(pFilterFunction as RowFilter, paramarray pFunctionParameters as variant) as variant()

Called as follows:

var tmp1() as variant = table0.ApplyFilterFunction(AddressOf BasicFieldFilter,“country”,“France”)

with BasicFieldFilter() defined as:

Function BasicFieldFilter(pRowIndex as integer, pRowCount as integer, pColumnNames() as string, pCellValues() as variant, paramarray pFunctionParameters as variant) as boolean

This first delegate is used in a similar way in another class.

The code compiles and execution passes the tests.

So, solved for me.

Note that the prototype of the delegate is defined with pFunctionParameters defined as an array, while the function used is defined with pFunctionParameters defined as a paramarray.

Thanks for the suggestion. Problem solved.

2 Likes

Because it never acted like a true ParamArray (i.e. allowing multiple individual arguments rather than just an array) it was misleading. The compiler is now stricter about what can be declared for Delegate parameters. For that particular function, the last parameter should always have been declared as an array of Variant, since that’s the only type you could pass without causing a compiler error or a runtime TypeMismatchException, even in 2025r1.1

The related issue is here: https://tracker.xojo.com/xojoinc/xojo/-/issues/64376

3 Likes

Understood. May I suggest someone update the documentation, since the mention “On Android, you cannot use ParamArray with a Delegate.” makes one believe it works for other platforms. And a mention in the release notes would probably avoid similar messages from other users. Thanks

2 Likes