cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Fully support function call expressions in Array literals

Fully support function call expressions in Array literals

Array literal syntax in Flexscript has an annoying quirk. If an expression for one of its elements is a function call that returns a 'num', 'str', 'node', or 'obj', Flexscript typechecker doesn't accept it.

// return_num() has 'num' as return type and returns 42;

// ERROR:
//{
//    Array xs = [return_num()]; // Command return_num does not return the required type.
//}

// ERROR:
//{
//    Array xs = [return_num().as(Variant)]; // Command return_num does not return the required type.
//}

// OK
int r = return_num();
Array xs = ;

One workaround is to save the value in a local variable, as in the example above. Another workaround is to change return type to 'var'.

Could you please update Flexscript type checker to accept Array elements which are expressions of type 'num', 'str', 'node', or 'obj'? They are the names used in the Return Type field of the user commands, but they're supposedly mapped to Flexscript types 'double', 'string', 'treenode', and 'Object' respectively, and can be converted to 'Variant', and thus saved into an 'Array':

The following are some of the valid parameters you can enter in the Parameters and Return Type fields:

ObjecttreenodenodeArrayobjstringstrnumarrayvar

 

Can't find what you're looking for? Ask the community or share your knowledge.

Submit Idea