I had similar problem in both Spark IDE (compiling from commandline in Spark cloud using spark-cli) and plain Arduino IDE. Something like this didn’t work:
bool a;
bool b;
if (a) {
...
} else if (b) {
...
}
This fixed the problem:
if (a == true) {
...
} else if (b == true) {
...
}
Edit: updated to mention the code had same bug on Spark, too