Page MenuHomeFeedback Tracker

Assignment as final statement in a called block produces an undefined return type for that block
New, NormalPublic

Description

It is straightforward to call a block such as the following

call { private _a = 0; _a = 1 }

However, the return value of such a block is not nil, but undefined. For example, executing the following

typeName call { private _a = 0; _a = 1 };

Produces an error at the typeName operator:

Error Generic error in expression

I'd like the return value of such a block be either nil or (probably more usefully) the assigned value at the end of the block. Each of the following statements produces no errors

typeName call { nil };
typeName call {};
typeName call { 1 }

The ideal would be that executing the following code

typeName call { private _a = 0; _a = 1 };

would produce the result of "SCALAR".

Note that the code

typeName call { private _a = 0 };

would produce the same result. It doesn't make any sense to create a private variable as the last statement of a block, but there is no harm in having the assigned value pass through to establish the return value of the code block.

Details

Severity
None
Resolution
Open
Reproducibility
N/A
Operating System
Windows 7
Category
Scripting
Steps To Reproduce

Enter the following in the debug console's Execute area:

typeName call { private _a = 0; _a = 1 };

and press LOCAL EXEC. An error will be generated.

Additional Information

This change would be valuable to anyone who creates function wrappers and wants to pass through the return value of the called function. As things stand right now, any such function wrappers will produce an error if a called function has an assignment statement at its end.

Event Timeline

JB47394 created this task.Oct 13 2018, 7:25 PM