A more proper fix for https://github.com/arrayfire/arrayfire/pull/1847
A more proper fix for #1847