The original code proves that FPC isn't treating the boolean parameter as a boolean but as a byte value. This is obvious because a boolean can only have the values 0 and 1, therefore it could never index the "error" string.
What exactly do you try to tell....
Boolean vs Byte (or any other storage) is not a conflict.
Using the bit patterns 00000000 and 00000001 in a Byte is merely a matter of representation. Not of how the logic works.
If I put 0 and 1 on a paper, how round does the zero has to be before what I wrote is no longer boolean?
There are 2 states (as you stated more than twice / pun intended). And those 2 states can be represented in a byte (or word or dword or 256bit container or a page of 1024 bytes ....).
And as long as you do use the container with only boolean operation (store either true or false) only those 2 states are there. So that is correct.
And by the very means of boolean logic itself, if the compiler test for one of the 2 states, and it is not that state, then it is the other.
In fact it only needs to test any one part from which it can tell the difference.
If on a paper the terms True/False are used, the all I (as reader) need to do is to check if it starts with a "T". From that I can tell what it is.
If you use typecasts with data that does not match the known representations, then the container is no longer for boolean use (you started using it for something else). And any attempt to use it as if it were boolean will not have a defined outcome.
But if you don't change its usage, then it will behave according to the boolean rules.