digitalRead method doesn't return a Boolean value. It returns an Integer.
From what I remember inside Arduino.h values of
HIGH are defined as being simply Integer
#define HIGH 0x1
#define LOW 0x0
I think that was changed to an Enum called
PinStatus but Enum can be treated as an Integer.
This means that you have to store results of
digitalRead inside Integer variable.
int value = digitalRead(8);
It was designed that way to easily cast values between Integer and Boolean. By (very smart) design choice Integer value of
LOW) will be cast to
false and every other value (for example
HIGH) will be cast to
! (Boolean NOT) can be used only with Boolean variables so the compiler needs to perform several "implicit casts". When it's smart enough it will assume you are know what you are doing and it will add the cast by itself.
By reading the error I see that the issue is happening when compiler tries to convert Boolean value into Integer. So this is implicitly evaluated correctly as a Boolean value
But when you try to put it inside a place for PinStatus you get the exception
cannot convert 'bool' to 'PinStatus'
Try adding an "explicit cast" to PinStatus:
It should fix the issue.
But I suggest splitting the code into several lines and adding a temporary variable. It makes debugging much easier. Trust the code optimizer that's built into the compiler. It will understand what you want to do and actual machine code will be the same.