How can I get this 8 year old VBA 64-bit compiler bug fixed?

Sub Test()
    Debug.Print ReturnFalse(New SomeClass)

    If ReturnFalse(New SomeClass) Then
        Debug.Print True
    Else
        Debug.Print False
    End If
    
    If True = ReturnFalse(New SomeClass) Then
        Debug.Print True
    Else
        Debug.Print False
    End If
End Sub

Returns

False
True
False

So If True = ReturnFalse(New SomeClass) Then fixes it

And for the loop this fixes it too

Do While True = ReturnFalse(New SomeClass)
    Debug.Print "Oh no!"
    Exit Do
Loop

Highly recommended to comment every usage of the workaround above so nobody removes that True = in the future (eg. because he develops in 32 bit and does not even run into the issue).

' Don't remove `True =` due to a compiler bug in x64 the condition would always be true. 
' See https://stackoverflow.com/questions/68034271/how-can-i-get-this-8-year-old-vba-64-bit-compiler-bug-fixed
If True = ReturnFalse(New SomeClass) Then

Even If ReturnFalse(New SomeClass) And False = True Then would be True with this bug.

Leave a Comment