Invalid delegate in blueprint when using reference argument

I’m trying to define an event delegate with a reference argument in order to use it as output value. This delegate is sent as parameter to the an UFunction:

DECLARE_DYNAMIC_DELEGATE_OneParam(FTestDelegate, bool&, Example);
...
UFUNCTION(BlueprintCallable, Category="Test")
void TestCondition(FTestDelegate Condition);

And when I try to use this function inside the blueprint, it doesn’t allow to assign the respective event:

However, without using reference in the delegate declaration and inside the blueprint, the event gets assigned without any problem.

Am I doing something wrong? Or is this a bug?

I am also having the same issue. Furthermore, if I let Unreal create the event for me by drag dropping from the Event pin and choosing “Add Custom Event”, it creates an event that does not have the reference parameters

With:

    DECLARE_DYNAMIC_DELEGATE_TwoParams(FMyDelegate, float&, X, float, Y);
...
MyObject* CreateBSRequestTest(UBlendSpaceBase* BS, bool Loops, const FMyDelegate& test);

This is what Unreal creates:

105100-example.png

This feels like a bug or limitation.

After some tests, I found that const reference parameters show up (but are not very useful I my case since, you know, I wanna change that value). Digging in the code, I found that my dynamic delegate’s signature has my X parameter with the flag CPF_OutParm but not CPF_ReferenceParm, which causes the pin to not be created (the check for creating a pin is !Param->HasAnyPropertyFlags(CPF_OutParm) || Param->HasAnyPropertyFlags(CPF_ReferenceParm))

Digging deeper, I found this bit of code in HeaderParser.cpp, line 3904:

if (MatchSymbol(TEXT("&")))
{
	switch (VariableCategory)
	{
		case EVariableCategory::RegularParameter:
		case EVariableCategory::Return:
		{
			Flags |= CPF_OutParm;

			//@TODO: UCREMOVAL: How to determine if we have a ref param?
			if (Flags & CPF_ConstParm)
			{
				Flags |= CPF_ReferenceParm;
			}
		}
		break;

Hum, TODO indeed.

This is probably far too late for the guy asking the question, but in case anyone else comes across this problem and finds this thread:

If you’re not interested in the initial value of the reference parameter, you can simply create a function that has input parameters for the regular (non-reference) parameters of the delegate and output parameters for the reference parameters of the delegate. Then create a Create Event node and select the function you just created. The resulting event should be accepted by the delegate slot.

However I still don’t know how to create delegates that accept real reference paramters…