LordGolias/sqf

Linter doesn't support different types of syntax for if statements and curly braces

Closed this issue · 3 comments

When using this kind of style of braces (don't worry I don't use them :D) the linter spews out an error:

if (typeName _current_ammoCount == "BOOL") then
{
	if (_current_ammoCount) then {_TurretAmmoPercentages pushBack 1} else {_TurretAmmoPercentages pushBack 0};
} else
{
	private _cfg_ammoCount = getNumber (configfile >> "CfgMagazines" >> _x >> "count");
	if (_cfg_ammoCount == 0) then {_TurretAmmoPercentages pushBack 1} else {_TurretAmmoPercentages pushBack (_current_ammoCount / _cfg_ammoCount)};
};

Error is:

functions_f_achilles\functions\common\fn_getVehicleAmmoDef.sqf
	[71,7]:error:Unary operator "if" only accepts argument of types [Boolean] (rhs is Number)
	[71,28]:error:Binary operator "then" arguments must be [(IfType,Array),(IfType,ElseType),(IfType,Code)] (lhs is Anything, rhs is ElseType)
	[71,32]:warning:helper type "ElseType" not evaluated

Can't reproduce:

    def test_bla(self):
        code = '''if (1 == 2) then
{
	if (1==1) then {} else {};
} 
else 
{
	if (1 == 1) then {} else {};
};'''
        analyzer = analyze(parse(code))
        print(analyzer.exceptions)
        self.assertEqual(len(analyzer.exceptions), 0)

Removed the variables because they were causing undefined variable warnings. If I put exactly what you wrote I get only undef. variables warnings.

Also can't reproduce with the above code 👍

This seems to be tied to #31