Granting purity of functions is very difficult in Julia, due to Julias concept of generic functions, which are by design redefineable at any time, in any module. Hashing is a perfect solution to prevent unintentionally changes.
I opened this issue, conclusion: @generated works as designed, using Base.invokelatest in a @generated function (or any function called from there) is forbidden. If it is used, behaviour of the program is undefined. This applies to the apparently working call Base.invokelatest(bitsizeof,T) in f1 and the strange error message of the subsequent call Base.invokelatest(typemax,T) in bitsizeof stating that there is a newer version of typemax which cannot be called.
If there is any issue, it is a documentation issue: doc on @generated and Base.invokelatest(typemax,T) does not explicitly state that it is not allowed to call Base.invokelatest from a @generated block. Stefan Karpinski admitted ‘It might be good to clarify this in the docs though.’