Verify code does not check if loop compare


I was just searching for hours for an error in my code in the cloud SDK which was not recognized by the verify function.
I wrote a if statement like this:
if (a = 1)
The verify does not complain that it should be
if (a == 1)
which I overlooked.

Would be great if this check can be implemented.


1 Like

@crisu, the syntax is not considered strictly incorrect, though some compilers will throw a warning (obviously not gcc!). :grinning:

1 Like

Because that is perfectly valid code!

Hence a lot of skilled programmers flip the statement round to this

if (1 == a)  // that will compile
if (1 = a)   // this won't

This would throw an error since a constant is no lvalue.

And even if the compiler threw a warning, ypu’d not get to see it with the Particle cloud build - unless you have another error that also causes the warnings to be displayed.

1 Like