Warning for commands taking precedence
rebelvg opened this issue · 5 comments
A few examples.
sleep 1 + 5;
{
systemChat str _x;
} forEach allPlayers select {!isPlayer _x};
In the first case, sleep will do 1 and ignore + operation, 1 + 5 should be in brackets to work. This doesn't produce any error in arma, but would be nice if your parser did.
Same with forEach, it ignores select and just goes with allPlayers, same, no error in-game.
Correction, forEach can return data, and select will be applied to that return. Still, this can lead to some weird problems, I'd say warning would be great here.
Good suggestion. Thank you @rebelvg for the different issues added here!
Glad to help somehow.
Tested this commit. This added warning for sleep. But forEach and select do not report anything wrong. Not sure how to define this case cause this example is a 50/50 case, I mean in case you want do a select on result of forEach it's right, but if you wan to do a forEach on result of select it's wrong and there should be brackets added.
Yes. I focused on the issue that is wrong 100%. In the forEach, we cannot tell if it is wrong. Specifically, the following example is valid:
{
if (_x == _player1) exitWith {[1,2]}
if (_x == _player2) exitWith {[1,3]}
} forEach allPlayers select 1
and returns 2, 3 or an error. I understand it is a funny construction, but since it is correct, I will not warn for it at the moment.
Gotcha.