Similar to #221, evaluating assignments as expression has some issues.
Example:
declare function a(): number[];
declare function b(): number;
declare function c(): number;
declare const d: number[];
let e = ( a()[b()] = c() );
Currently produces:
local e = ((function() a()[(b())+1] = c(); return a()[(b())+1] end)());
The problem here being that a and b are called twice having potentially undesired effects.
A solution could be to cache with a temp:
local e = ((function() local __temp = c(); a()[(b())+1] = __temp; return __temp end)());
But there's a subtle problem with this. Now, c is called before a and b. This would cause issues if c depends on a or b. shudder
The only way I can think of to execute it all correctly would be to use another lambda:
local e = ((function() local __temp; a()[(b())+1] = (function() __temp = c(); return __temp end)(); return __temp end)());
At this point things should work correctly but it's very ugly and not great performance-wise.
Similar to #221, evaluating assignments as expression has some issues.
Example:
Currently produces:
The problem here being that a and b are called twice having potentially undesired effects.
A solution could be to cache with a temp:
But there's a subtle problem with this. Now, c is called before a and b. This would cause issues if c depends on a or b. shudder
The only way I can think of to execute it all correctly would be to use another lambda:
At this point things should work correctly but it's very ugly and not great performance-wise.