You can make cat
type-stable, like so:
julia> @code_warntype cat(B, B, dims=2)
...
Body::Any
julia> @code_warntype hcat(B, B)
...
Body::Matrix{Int64}
julia> @code_warntype cat(B, B, dims=Val(2))
...
Body::Matrix{Int64}
The issue with the first one is that cat(B, B; dims=1) isa Vector
– same input types, but different output.