Idea

Serge A avatar image
1 Like"
Serge A suggested

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 = [r];

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


flexscript
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

No Comments

·

Write a Comment

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Your Opinion Counts

Share your great idea, or help out by voting for other people's ideas.